re PR tree-optimization/58497 (SLP vectorizes identical operations)
authorRichard Biener <rguenther@suse.de>
Thu, 12 Nov 2015 09:00:37 +0000 (09:00 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 12 Nov 2015 09:00:37 +0000 (09:00 +0000)
2015-11-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/58497
* tree-vect-generic.c: Include gimplify.h.
(tree_vec_extract): Lookup constant/constructor DEFs.
(do_cond): Unshare cond.

From-SVN: r230216

gcc/ChangeLog
gcc/tree-vect-generic.c

index 815bb089575c905c22e779b9b972a802c425c315..d292656e8d1691f9ac8c7d0dc52a1a4d9e6ec255 100644 (file)
@@ -1,3 +1,10 @@
+2015-11-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/58497
+       * tree-vect-generic.c: Include gimplify.h.
+       (tree_vec_extract): Lookup constant/constructor DEFs.
+       (do_cond): Unshare cond.
+
 2015-11-12  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/i386.c (ix86_legitimate_combined_insn): Reject
index 5883db8abd6c30418a4a8f5c4125e269c6c6fae8..af1af17a42536d98278e7e9364314994796baf6d 100644 (file)
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-eh.h"
 #include "gimple-iterator.h"
 #include "gimplify-me.h"
+#include "gimplify.h"
 #include "tree-cfg.h"
 
 
@@ -105,6 +106,15 @@ static inline tree
 tree_vec_extract (gimple_stmt_iterator *gsi, tree type,
                  tree t, tree bitsize, tree bitpos)
 {
+  if (TREE_CODE (t) == SSA_NAME)
+    {
+      gimple *def_stmt = SSA_NAME_DEF_STMT (t);
+      if (is_gimple_assign (def_stmt)
+         && (gimple_assign_rhs_code (def_stmt) == VECTOR_CST
+             || (bitpos
+                 && gimple_assign_rhs_code (def_stmt) == CONSTRUCTOR)))
+       t = gimple_assign_rhs1 (def_stmt);
+    }
   if (bitpos)
     {
       if (TREE_CODE (type) == BOOLEAN_TYPE)
@@ -1419,7 +1429,7 @@ do_cond (gimple_stmt_iterator *gsi, tree inner_type, tree a, tree b,
   if (TREE_CODE (TREE_TYPE (b)) == VECTOR_TYPE)
     b = tree_vec_extract (gsi, inner_type, b, bitsize, bitpos);
   tree cond = gimple_assign_rhs1 (gsi_stmt (*gsi));
-  return gimplify_build3 (gsi, code, inner_type, cond, a, b);
+  return gimplify_build3 (gsi, code, inner_type, unshare_expr (cond), a, b);
 }
 
 /* Expand a vector COND_EXPR to scalars, piecewise.  */