Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > b5e52bbfb4bb11a6cbed452927fba979 > files > 48

gcc-4.1.2-50.el5.src.rpm

2008-02-20  Michael Matz  <matz@suse.de>

	PR target/35264
	* config/i386/i386.c (ix86_expand_branch): Add missing breaks.

	* gcc.dg/pr35264.c: New testcase.

2007-12-14  Jakub Jelinek  <jakub@redhat.com>

	PR target/29978
	* config/i386/i386.c (ix86_expand_branch): Optimize LE/LEU/GT/GTU
	DImode comparisons against constant with all 1's in the lower word.

	* gcc.target/i386/pr29978.c: New test.

--- gcc/config/i386/i386.c	(revision 130937)
+++ gcc/config/i386/i386.c	(revision 130938)
@@ -10496,16 +10496,30 @@ ix86_expand_branch (enum rtx_code code, 
 
 	/* Otherwise, if we are doing less-than or greater-or-equal-than,
 	   op1 is a constant and the low word is zero, then we can just
-	   examine the high word.  */
+	   examine the high word.  Similarly for low word -1 and
+	   less-or-equal-than or greater-than.  */
 
-	if (GET_CODE (hi[1]) == CONST_INT && lo[1] == const0_rtx)
+	if (GET_CODE (hi[1]) == CONST_INT)
 	  switch (code)
 	    {
 	    case LT: case LTU: case GE: case GEU:
-	      ix86_compare_op0 = hi[0];
-	      ix86_compare_op1 = hi[1];
-	      ix86_expand_branch (code, label);
-	      return;
+	      if (lo[1] == const0_rtx)
+		{
+		  ix86_compare_op0 = hi[0];
+		  ix86_compare_op1 = hi[1];
+		  ix86_expand_branch (code, label);
+		  return;
+		}
+	      break;
+	    case LE: case LEU: case GT: case GTU:
+	      if (lo[1] == constm1_rtx)
+		{
+		  ix86_compare_op0 = hi[0];
+		  ix86_compare_op1 = hi[1];
+		  ix86_expand_branch (code, label);
+		  return;
+		}
+	      break;
 	    default:
 	      break;
 	    }
--- gcc/testsuite/gcc.target/i386/pr29978.c	(revision 0)
+++ gcc/testsuite/gcc.target/i386/pr29978.c	(revision 130938)
@@ -0,0 +1,16 @@
+/* PR target/29978 */
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+void g ();
+
+void
+f (long long v)
+{
+  if (v > 0xfffffffffLL)
+    g ();
+  g ();
+}
+
+/* Verify there are no redundant jumps jl .L2; jle .L2 */
+/* { dg-final { scan-assembler-not "jl\[^e\]*\\.L" { target ilp32 } } } */
--- gcc/testsuite/gcc.dg/pr35264.c	(revision 0)
+++ gcc/testsuite/gcc.dg/pr35264.c	(revision 0)
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+extern void abort(void);
+long long __attribute__((noinline)) get(void)
+{
+  return -2;
+}
+long long __attribute__((noinline)) get(void);
+int __attribute__((noinline)) check(void)
+{
+ long long lcn;
+
+ lcn = get();
+ if (lcn >= 0 || lcn == -1)
+  return 0;
+
+ return -1;
+}
+int main()
+{
+  if (check() == 0)
+    abort();
+  return 0;
+}