tree-optimization/97886 - deal with strange LC PHI nodes
authorRichard Biener <rguenther@suse.de>
Wed, 18 Nov 2020 09:32:29 +0000 (10:32 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 18 Nov 2020 10:25:00 +0000 (11:25 +0100)
This makes vectorization properly assign vector types to PHI
nodes that copy from externals on loop exit edges.

2020-11-18  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97886
* tree-vect-loop.c (vectorizable_lc_phi): Properly assign
vector types to invariants for SLP.

gcc/tree-vect-loop.c

index ecaaf0116d3022c9709e11cacd7f2ffa07a77708..856bbfebf7ca2345b8983cb26b303a859bff113c 100644 (file)
@@ -7593,6 +7593,17 @@ vectorizable_lc_phi (loop_vec_info loop_vinfo,
 
   if (!vec_stmt) /* transformation not required.  */
     {
+      /* Deal with copies from externs or constants that disguise as
+        loop-closed PHI nodes (PR97886).  */
+      if (slp_node
+         && !vect_maybe_update_slp_op_vectype (SLP_TREE_CHILDREN (slp_node)[0],
+                                               SLP_TREE_VECTYPE (slp_node)))
+       {
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                            "incompatible vector types for invariants\n");
+         return false;
+       }
       STMT_VINFO_TYPE (stmt_info) = lc_phi_info_type;
       return true;
     }