OSDN Git Service

PR target/29978
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 14 Dec 2007 18:00:39 +0000 (18:00 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 14 Dec 2007 18:00:39 +0000 (18:00 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130938 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr29978.c [new file with mode: 0644]

index b006b49..0875708 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2007-12-14  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/sse.md (sse4_2_pcmpestr): Use reg_not_xmm0_operand
index fcae077..95a3496 100644 (file)
@@ -12093,16 +12093,28 @@ ix86_expand_branch (enum rtx_code code, rtx label)
 
        /* 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 (CONST_INT_P (hi[1]) && lo[1] == const0_rtx)
+       if (CONST_INT_P (hi[1]))
          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;
+               }
+           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;
+               }
            default:
              break;
            }
index c6ce8eb..89c0228 100644 (file)
@@ -1,3 +1,8 @@
+2007-12-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/29978
+       * gcc.target/i386/pr29978.c: New test.
+
 2007-12-14  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/sse-12.c (dg-options): Use -msse4
diff --git a/gcc/testsuite/gcc.target/i386/pr29978.c b/gcc/testsuite/gcc.target/i386/pr29978.c
new file mode 100644 (file)
index 0000000..8c0bf9f
--- /dev/null
@@ -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 } } } */