This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, vectorizer] Fix PR tree-optimization/41008


Hi,

This patch fixes the retrieval of operands of cond_expr for the case that
the condition is not a comparison.

Bootstrapped with vectorization enabled and tested on x86_64-suse-linux.

Committed revision 150591.

Ira


ChangeLog:

      PR tree-optimization/41008
      * tree-vect-loop.c (vect_is_simple_reduction): Get operands
      from condition only in case it's a comparison. Adjust checks.

testsuite/Changelog:

      PR tree-optimization/41008
      * gcc.dg/vect/O1-pr41008.c: New test.


Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c    (revision 150586)
+++ tree-vect-loop.c    (working copy)
@@ -1705,8 +1705,13 @@ vect_is_simple_reduction (loop_vec_info
           return NULL;
         }

-      op3 = TREE_OPERAND (TREE_OPERAND (gimple_assign_rhs1 (def_stmt), 0),
0);
-      op4 = TREE_OPERAND (TREE_OPERAND (gimple_assign_rhs1 (def_stmt), 0),
1);
+      op3 = TREE_OPERAND (gimple_assign_rhs1 (def_stmt), 0);
+      if (COMPARISON_CLASS_P (op3))
+        {
+          op4 = TREE_OPERAND (op3, 1);
+          op3 = TREE_OPERAND (op3, 0);
+        }
+
       op1 = TREE_OPERAND (gimple_assign_rhs1 (def_stmt), 1);
       op2 = TREE_OPERAND (gimple_assign_rhs1 (def_stmt), 2);

@@ -1750,10 +1755,14 @@ vect_is_simple_reduction (loop_vec_info
           print_generic_expr (vect_dump, TREE_TYPE (op1), TDF_SLIM);
           fprintf (vect_dump, ",");
           print_generic_expr (vect_dump, TREE_TYPE (op2), TDF_SLIM);
-          if (op3 && op4)
+          if (op3)
             {
               fprintf (vect_dump, ",");
               print_generic_expr (vect_dump, TREE_TYPE (op3), TDF_SLIM);
+            }
+
+          if (op4)
+            {
               fprintf (vect_dump, ",");
               print_generic_expr (vect_dump, TREE_TYPE (op4), TDF_SLIM);
             }
Index: testsuite/gcc.dg/vect/O1-pr41008.c
===================================================================
--- testsuite/gcc.dg/vect/O1-pr41008.c  (revision 0)
+++ testsuite/gcc.dg/vect/O1-pr41008.c  (revision 0)
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+
+double heating[2][2];
+
+void foo (int, int);
+
+void map_do()
+{
+  int jsav, ksav, k, j;
+
+  for(k = 0; k < 2; k++)
+    for(j = 0; j < 2; j++)
+      if (heating[k][j] > 0.)
+        {
+          jsav = j;
+          ksav = k;
+        }
+
+  foo (jsav, ksav);
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
+


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]