]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386.c (ix86_prepare_sse_fp_compare_args): For GE/GT/UNLE/UNLT swap arguments and...
authorJakub Jelinek <jakub@redhat.com>
Fri, 23 Sep 2011 14:35:05 +0000 (16:35 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 23 Sep 2011 14:35:05 +0000 (16:35 +0200)
* config/i386/i386.c (ix86_prepare_sse_fp_compare_args): For
GE/GT/UNLE/UNLT swap arguments and condition even for TARGET_AVX.

* gcc.target/i386/avxfp-1.c: New test.
* gcc.target/i386/avxfp-2.c: New test.

From-SVN: r179119

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/avxfp-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avxfp-2.c [new file with mode: 0644]

index 424404f40f4e53f4c2c8427651219bd012fd39de..dec03cfdfde0c48c5b1df975f775c77b5565d076 100644 (file)
@@ -1,3 +1,8 @@
+2011-09-23  Jakub Jelinek  <jakub@redhat.com>
+
+       * config/i386/i386.c (ix86_prepare_sse_fp_compare_args): For
+       GE/GT/UNLE/UNLT swap arguments and condition even for TARGET_AVX.
+
 2011-09-23  Ian Lance Taylor  <iant@google.com>
 
        * godump.c (go_define): Treat a single character in single quotes,
index 954b879c0fc0872b0ed7af1bf49a48ec97c1598c..291d73f49194811432fb72f5a7b9496112ac8f92 100644 (file)
@@ -18735,15 +18735,13 @@ ix86_prepare_sse_fp_compare_args (rtx dest, enum rtx_code code,
 {
   rtx tmp;
 
-  /* AVX supports all the needed comparisons, no need to swap arguments
-     nor help reload.  */
-  if (TARGET_AVX)
-    return code;
-
   switch (code)
     {
     case LTGT:
     case UNEQ:
+      /* AVX supports all the needed comparisons.  */
+      if (TARGET_AVX)
+       break;
       /* We have no LTGT as an operator.  We could implement it with
         NE & ORDERED, but this requires an extra temporary.  It's
         not clear that it's worth it.  */
@@ -18760,6 +18758,9 @@ ix86_prepare_sse_fp_compare_args (rtx dest, enum rtx_code code,
     case NE:
     case UNORDERED:
     case ORDERED:
+      /* AVX has 3 operand comparisons, no need to swap anything.  */
+      if (TARGET_AVX)
+       break;
       /* For commutative operators, try to canonicalize the destination
         operand to be first in the comparison - this helps reload to
         avoid extra moves.  */
@@ -18771,8 +18772,10 @@ ix86_prepare_sse_fp_compare_args (rtx dest, enum rtx_code code,
     case GT:
     case UNLE:
     case UNLT:
-      /* These are not supported directly.  Swap the comparison operands
-        to transform into something that is supported.  */
+      /* These are not supported directly before AVX, and furthermore
+        ix86_expand_sse_fp_minmax only optimizes LT/UNGE.  Swap the
+        comparison operands to transform into something that is
+        supported.  */
       tmp = *pop0;
       *pop0 = *pop1;
       *pop1 = tmp;
index c649043085a8bc2a31dbd86e0befbedc5d3d810a..37f5beca9ea9ec5b23ed9a0d17c85c2e613d4b3f 100644 (file)
@@ -1,3 +1,8 @@
+2011-09-23  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.target/i386/avxfp-1.c: New test.
+       * gcc.target/i386/avxfp-2.c: New test.
+
 2011-09-23  Terry Guo  <terry.guo@arm.com>
 
        * gcc.c-torture/execute/941014-1.x: Deleted.
diff --git a/gcc/testsuite/gcc.target/i386/avxfp-1.c b/gcc/testsuite/gcc.target/i386/avxfp-1.c
new file mode 100644 (file)
index 0000000..70bc8f1
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx -mfpmath=sse" } */
+/* { dg-final { scan-assembler "vmaxsd" } } */
+/* { dg-final { scan-assembler "vminsd" } } */
+double x;
+t()
+{
+  x=x>5?x:5;
+}
+
+double x;
+q()
+{
+  x=x<5?x:5;
+}
diff --git a/gcc/testsuite/gcc.target/i386/avxfp-2.c b/gcc/testsuite/gcc.target/i386/avxfp-2.c
new file mode 100644 (file)
index 0000000..c34a1bd
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx -mfpmath=sse" } */
+/* { dg-final { scan-assembler "vmaxsd" } } */
+/* { dg-final { scan-assembler "vminsd" } } */
+double x;
+q()
+{
+  x=x<5?5:x;
+}
+
+double x;
+q1()
+{
+  x=x>5?5:x;
+}