[PATCH, AARCH64] Fix unrecognizable insn issue with vcond against 0.0f
authorJames Greenhalgh <james.greenhalgh@arm.com>
Thu, 11 Apr 2013 08:58:34 +0000 (08:58 +0000)
committerJames Greenhalgh <jgreenhalgh@gcc.gnu.org>
Thu, 11 Apr 2013 08:58:34 +0000 (08:58 +0000)
gcc/
* config/aarch64/aarch64-simd.md (aarch64_vcond_internal): Fix
floating-point vector comparisons against 0.

gcc/testsuite/
    * gcc.target/aarch64/vect-fcm.x: Add check for zero forms of
inverse operands.
* gcc.target/aarch64/vect-fcm-eq-d.c: Check that new zero form
loop is vectorized.
    * gcc.target/aarch64/vect-fcm-eq-f.c: Likewise.
    * gcc.target/aarch64/vect-fcm-ge-d.c: Check that new zero form
loop is vectorized and that the correct instruction is generated.
    * gcc.target/aarch64/vect-fcm-ge-f.c: Likewise.
    * gcc.target/aarch64/vect-fcm-gt-d.c: Likewise.
    * gcc.target/aarch64/vect-fcm-gt-f.c: Likewise.

From-SVN: r197741

gcc/ChangeLog
gcc/config/aarch64/aarch64-simd.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/vect-fcm-eq-d.c
gcc/testsuite/gcc.target/aarch64/vect-fcm-eq-f.c
gcc/testsuite/gcc.target/aarch64/vect-fcm-ge-d.c
gcc/testsuite/gcc.target/aarch64/vect-fcm-ge-f.c
gcc/testsuite/gcc.target/aarch64/vect-fcm-gt-d.c
gcc/testsuite/gcc.target/aarch64/vect-fcm-gt-f.c
gcc/testsuite/gcc.target/aarch64/vect-fcm.x

index bab67ab7b01ff9b8232312569085d6ef640e35b5..24a179275c5e098b743f93ed1ba37fd5e3d161f1 100644 (file)
@@ -1,3 +1,8 @@
+2013-04-11  James Greenhalgh  <james.greenhalgh@arm.com>
+
+       * config/aarch64/aarch64-simd.md (aarch64_vcond_internal): Fix
+       floating-point vector comparisons against 0.
+
 2013-04-11  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/56899
index 92dcfc0c57b8e2ef4874f72581e8e8452dcd6e5e..f72a2e2ff4b765b207e27d63f2e0edbd4a2e6134 100644 (file)
   "TARGET_SIMD"
 {
   int inverse = 0;
+  int use_zero_form = 0;
   int swap_bsl_operands = 0;
   rtx mask = gen_reg_rtx (<V_cmp_result>mode);
   rtx tmp = gen_reg_rtx (<V_cmp_result>mode);
   switch (GET_CODE (operands[3]))
     {
     case GE:
+    case GT:
     case LE:
+    case LT:
     case EQ:
-      if (!REG_P (operands[5])
-         && (operands[5] != CONST0_RTX (<MODE>mode)))
-       operands[5] = force_reg (<MODE>mode, operands[5]);
-      break;
+      if (operands[5] == CONST0_RTX (<MODE>mode))
+       {
+         use_zero_form = 1;
+         break;
+       }
+      /* Fall through.  */
     default:
       if (!REG_P (operands[5]))
        operands[5] = force_reg (<MODE>mode, operands[5]);
         a GT b -> a GT b
         a LE b -> b GE a
         a LT b -> b GT a
-        a EQ b -> a EQ b  */
+        a EQ b -> a EQ b
+        Note that there also exist direct comparison against 0 forms,
+        so catch those as a special case.  */
+      if (use_zero_form)
+       {
+         inverse = 0;
+         switch (GET_CODE (operands[3]))
+           {
+           case LT:
+             base_comparison = gen_aarch64_cmlt<mode>;
+             break;
+           case LE:
+             base_comparison = gen_aarch64_cmle<mode>;
+             break;
+           default:
+             /* Do nothing, other zero form cases already have the correct
+                base_comparison.  */
+             break;
+           }
+       }
 
       if (!inverse)
        emit_insn (base_comparison (mask, operands[4], operands[5]));
index 62557021bba8be0acf7a62ee9384863870dc5f77..abe23e239f765ddbe40e41ab736f127dd63a370d 100644 (file)
@@ -1,3 +1,16 @@
+2013-04-11  James Greenhalgh  <james.greenhalgh@arm.com>
+
+       * gcc.target/aarch64/vect-fcm.x: Add check for zero forms of
+       inverse operands.
+       * gcc.target/aarch64/vect-fcm-eq-d.c: Check that new zero form
+       loop is vectorized.
+       * gcc.target/aarch64/vect-fcm-eq-f.c: Likewise.
+       * gcc.target/aarch64/vect-fcm-ge-d.c: Check that new zero form
+       loop is vectorized and that the correct instruction is generated.
+       * gcc.target/aarch64/vect-fcm-ge-f.c: Likewise.
+       * gcc.target/aarch64/vect-fcm-gt-d.c: Likewise.
+       * gcc.target/aarch64/vect-fcm-gt-f.c: Likewise.
+
 2013-04-11  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/56899
index b6fb5ae8798849970a723e52edf2c55b5aaf1480..19ecd63b1d1371beb40d75220dac0e3f53d2d959 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "vect-fcm.x"
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" } } */
 /* { dg-final { scan-assembler "fcmeq\\tv\[0-9\]+\.2d, v\[0-9\]+\.2d, v\[0-9\]+\.2d" } } */
 /* { dg-final { scan-assembler "fcmeq\\tv\[0-9\]+\.2d, v\[0-9\]+\.2d, 0" } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
index 283d34fb80a234495bea5bbb987b358a5757e9ff..30be5adf529fd9ed96dfc4151e84111bd89b24f3 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "vect-fcm.x"
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" } } */
 /* { dg-final { scan-assembler "fcmeq\\tv\[0-9\]+\.\[24\]s, v\[0-9\]+\.\[24\]s, v\[0-9\]+\.\[24\]s" } } */
 /* { dg-final { scan-assembler "fcmeq\\tv\[0-9\]+\.\[24\]s, v\[0-9\]+\.\[24\]s, 0" } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
index 868e1f8e60d6cdda497766da3ff116b487bc3638..b922833be8c97a687f3495f24f8b758d42c12c21 100644 (file)
@@ -7,8 +7,9 @@
 
 #include "vect-fcm.x"
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" } } */
 /* { dg-final { scan-assembler "fcmge\\tv\[0-9\]+\.2d, v\[0-9\]+\.2d, v\[0-9\]+\.2d" } } */
 /* { dg-final { scan-assembler "fcmge\\tv\[0-9\]+\.2d, v\[0-9\]+\.2d, 0" } } */
+/* { dg-final { scan-assembler "fcmlt\\tv\[0-9\]+\.2d, v\[0-9\]+\.2d, 0" } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
 /* { dg-final { cleanup-saved-temps } } */
index e3258f3641ebfd7679ccb9826648d6424dfba40a..04d3533ffe3657f22581804b5e412f052447a6b7 100644 (file)
@@ -7,8 +7,9 @@
 
 #include "vect-fcm.x"
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" } } */
 /* { dg-final { scan-assembler "fcmge\\tv\[0-9\]+\.\[24\]s, v\[0-9\]+\.\[24\]s, v\[0-9\]+\.\[24\]s" } } */
 /* { dg-final { scan-assembler "fcmge\\tv\[0-9\]+\.\[24\]s, v\[0-9\]+\.\[24\]s, 0" } } */
+/* { dg-final { scan-assembler "fcmlt\\tv\[0-9\]+\.\[24\]s, v\[0-9\]+\.\[24\]s, 0" } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
 /* { dg-final { cleanup-saved-temps } } */
index ed8b452159146c8ce54980afd2b0a09992aff0d5..421a04acfb407655b5bd56e5900a2ed6d7f5eba3 100644 (file)
@@ -7,8 +7,9 @@
 
 #include "vect-fcm.x"
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" } } */
 /* { dg-final { scan-assembler "fcmgt\\tv\[0-9\]+\.2d, v\[0-9\]+\.2d, v\[0-9\]+\.2d" } } */
 /* { dg-final { scan-assembler "fcmgt\\tv\[0-9\]+\.2d, v\[0-9\]+\.2d, 0" } } */
+/* { dg-final { scan-assembler "fcmle\\tv\[0-9\]+\.2d, v\[0-9\]+\.2d, 0" } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
 /* { dg-final { cleanup-saved-temps } } */
index e90a87581d3c7f94a070bef6bf2d1d16e83d1881..cdeab14e0ed90f75162deb4900531d39f2631965 100644 (file)
@@ -7,8 +7,9 @@
 
 #include "vect-fcm.x"
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" } } */
 /* { dg-final { scan-assembler "fcmgt\\tv\[0-9\]+\.\[24\]s, v\[0-9\]+\.\[24\]s, v\[0-9\]+\.\[24\]s" } } */
 /* { dg-final { scan-assembler "fcmgt\\tv\[0-9\]+\.\[24\]s, v\[0-9\]+\.\[24\]s, 0" } } */
+/* { dg-final { scan-assembler "fcmle\\tv\[0-9\]+\.\[24\]s, v\[0-9\]+\.\[24\]s, 0" } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
 /* { dg-final { cleanup-saved-temps } } */
index 7e51bef0ce2430f109c45a193b3f166ed86f43ce..803861b02930cf54d979b556c2f2c083b6adf7d6 100644 (file)
@@ -40,6 +40,15 @@ foobar (FTYPE *in1, FTYPE *in2, FTYPE *output)
     output[i] = (in1[i] OP 0.0) ? 4.0 : 2.0;
 }
 
+void
+foobarbar (FTYPE *in1, FTYPE *in2, FTYPE *output)
+{
+  int i = 0;
+  /* Vectorizable.  */
+  for (i = 0; i < N; i++)
+    output[i] = (in1[i] INV_OP 0.0) ? 4.0 : 2.0;
+}
+
 int
 main (int argc, char **argv)
 {
@@ -51,6 +60,11 @@ main (int argc, char **argv)
   for (i = 0; i < N; i++)
     if (out1[i] != out2[i])
       abort ();
+  foobar (input1, input2, out1);
+  foobarbar (input1, input2, out2);
+  for (i = 0; i < N; i++)
+    if (out1[i] == out2[i])
+      abort ();
   return 0;
 }