re PR middle-end/33187 (Missed cmove opportunity)
authorUros Bizjak <ubizjak@gmail.com>
Tue, 4 Sep 2007 10:07:19 +0000 (12:07 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Tue, 4 Sep 2007 10:07:19 +0000 (12:07 +0200)
       PR middle-end/33187
       * combine.c (subst): Do not try to simplify X if it represents load
       of FP constant from the constant pool via float extension.

testsuite/ChangeLog:

       PR middle-end/33187
       * gcc.target/i386/cmov7.c: New file.

From-SVN: r128072

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

index 630a118ae98d263c49da9b959d9d15aaf4d98e1e..e3c0ea4a8263ed1824c148569f4b15d17962e5d2 100644 (file)
@@ -1,3 +1,9 @@
+2007-09-04  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR middle-end/33187
+       * combine.c (subst): Do not try to simplify X if it represents load
+       of FP constant from the constant pool via float extension.
+
 2007-09-04  Ben Elliston  <bje@au.ibm.com>
 
        * c-opts.c: Include "tm_p.h".
index c794e11857f813df22c4c1bf162958e8975e34ac..b2bc7806f7bcaa3d9624861d2d841eb546262d52 100644 (file)
@@ -4478,6 +4478,18 @@ subst (rtx x, rtx from, rtx to, int in_dest, int unique_copy)
        }
     }
 
+  /* Check if we are loading something from the constant pool via float
+     extension; in this case we would undo compress_float_constant
+     optimization and degenerate constant load to an immediate value.  */
+  if (GET_CODE (x) == FLOAT_EXTEND
+      && MEM_P (XEXP (x, 0))
+      && MEM_READONLY_P (XEXP (x, 0)))
+    {
+      rtx tmp = avoid_constant_pool_reference (x);
+      if (x != tmp)
+        return x;
+    }
+
   /* Try to simplify X.  If the simplification changed the code, it is likely
      that further simplification will help, so loop, but limit the number
      of repetitions that will be performed.  */
index 465aaa29b6f280397682a055ea8842eb1f40b181..1db7371f60286a8aa9000a3487d63029e2a1674a 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-04  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR middle-end/33187
+       * gcc.target/i386/cmov7.c: New file.
+
 2007-09-04  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/sse4a-check.h: New file.
diff --git a/gcc/testsuite/gcc.target/i386/cmov7.c b/gcc/testsuite/gcc.target/i386/cmov7.c
new file mode 100644 (file)
index 0000000..b5d50d7
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR middle-end/33187 */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=k8 -ffast-math -mfpmath=387" } */
+/* { dg-final { scan-assembler "fcmov" } } */
+
+/* compress_float_constant generates load + float_extend
+   sequence which combine pass failed to combine into
+   (set (reg:DF) (float_extend:DF (mem:SF (symbol_ref...)))).  */
+
+double
+sgn (double __x)
+{
+  return __x >= 0.0 ? 1.0 : -1.0;
+}