tree-optimization/97466 - remove spurious assert
authorRichard Biener <rguenther@suse.de>
Mon, 19 Oct 2020 09:07:36 +0000 (11:07 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 19 Oct 2020 09:35:24 +0000 (11:35 +0200)
This removes an assertion that was supposed to be only for temporary
debugging.  I've also re-indented the code which I missed as well.

2020-10-19  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97466
* tree-vect-slp.c (vect_get_and_check_slp_defs): Remove
spurious assert, re-indent.

gcc/tree-vect-slp.c

index c3e6d67067cbf8ca77be54df8a1b954a347e0eb0..a2fbbc56bcc2c5cd8e5ce36ad9e3a1ea0657c03f 100644 (file)
@@ -531,78 +531,74 @@ vect_get_and_check_slp_defs (vec_info *vinfo, unsigned char swap,
       oprnd = oprnd_info->ops[stmt_num];
       tree type = TREE_TYPE (oprnd);
 
-         if (!types_compatible_p (oprnd_info->first_op_type, type))
+      if (!types_compatible_p (oprnd_info->first_op_type, type))
+       {
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                            "Build SLP failed: different operand types\n");
+         return 1;
+       }
+
+      /* Not first stmt of the group, check that the def-stmt/s match
+        the def-stmt/s of the first stmt.  Allow different definition
+        types for reduction chains: the first stmt must be a
+        vect_reduction_def (a phi node), and the rest
+        end in the reduction chain.  */
+      if ((!vect_def_types_match (oprnd_info->first_dt, dt)
+          && !(oprnd_info->first_dt == vect_reduction_def
+               && !STMT_VINFO_DATA_REF (stmt_info)
+               && REDUC_GROUP_FIRST_ELEMENT (stmt_info)
+               && def_stmt_info
+               && !STMT_VINFO_DATA_REF (def_stmt_info)
+               && (REDUC_GROUP_FIRST_ELEMENT (def_stmt_info)
+                   == REDUC_GROUP_FIRST_ELEMENT (stmt_info))))
+         || (!STMT_VINFO_DATA_REF (stmt_info)
+             && REDUC_GROUP_FIRST_ELEMENT (stmt_info)
+             && ((!def_stmt_info
+                  || STMT_VINFO_DATA_REF (def_stmt_info)
+                  || (REDUC_GROUP_FIRST_ELEMENT (def_stmt_info)
+                      != REDUC_GROUP_FIRST_ELEMENT (stmt_info)))
+                 != (oprnd_info->first_dt != vect_reduction_def))))
+       {
+         /* Try swapping operands if we got a mismatch.  For BB
+            vectorization only in case it will clearly improve things.  */
+         if (i == commutative_op && !swapped
+             && (!is_a <bb_vec_info> (vinfo)
+                 || (!vect_def_types_match ((*oprnds_info)[i+1]->first_dt,
+                                            dts[i+1])
+                     && (vect_def_types_match (oprnd_info->first_dt, dts[i+1])
+                         || vect_def_types_match
+                              ((*oprnds_info)[i+1]->first_dt, dts[i])))))
            {
-             gcc_assert ((i != commutative_op
-                          && (commutative_op == -1U
-                              || i != commutative_op + 1)));
              if (dump_enabled_p ())
-               dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                                "Build SLP failed: different operand types\n");
-             return 1;
+               dump_printf_loc (MSG_NOTE, vect_location,
+                                "trying swapped operands\n");
+             std::swap (dts[i], dts[i+1]);
+             std::swap ((*oprnds_info)[i]->def_stmts[stmt_num],
+                        (*oprnds_info)[i+1]->def_stmts[stmt_num]);
+             std::swap ((*oprnds_info)[i]->ops[stmt_num],
+                        (*oprnds_info)[i+1]->ops[stmt_num]);
+             swapped = true;
+             continue;
            }
 
-         /* Not first stmt of the group, check that the def-stmt/s match
-            the def-stmt/s of the first stmt.  Allow different definition
-            types for reduction chains: the first stmt must be a
-            vect_reduction_def (a phi node), and the rest
-            end in the reduction chain.  */
-         if ((!vect_def_types_match (oprnd_info->first_dt, dt)
-              && !(oprnd_info->first_dt == vect_reduction_def
-                   && !STMT_VINFO_DATA_REF (stmt_info)
-                   && REDUC_GROUP_FIRST_ELEMENT (stmt_info)
-                   && def_stmt_info
-                   && !STMT_VINFO_DATA_REF (def_stmt_info)
-                   && (REDUC_GROUP_FIRST_ELEMENT (def_stmt_info)
-                       == REDUC_GROUP_FIRST_ELEMENT (stmt_info))))
-             || (!STMT_VINFO_DATA_REF (stmt_info)
-                 && REDUC_GROUP_FIRST_ELEMENT (stmt_info)
-                 && ((!def_stmt_info
-                      || STMT_VINFO_DATA_REF (def_stmt_info)
-                      || (REDUC_GROUP_FIRST_ELEMENT (def_stmt_info)
-                          != REDUC_GROUP_FIRST_ELEMENT (stmt_info)))
-                     != (oprnd_info->first_dt != vect_reduction_def))))
+         if (is_a <bb_vec_info> (vinfo))
            {
-             /* Try swapping operands if we got a mismatch.  For BB
-                vectorization only in case it will clearly improve things.  */
-             if (i == commutative_op && !swapped
-                 && (!is_a <bb_vec_info> (vinfo)
-                     || (!vect_def_types_match ((*oprnds_info)[i+1]->first_dt,
-                                                dts[i+1])
-                         && (vect_def_types_match (oprnd_info->first_dt,
-                                                   dts[i+1])
-                             || vect_def_types_match
-                                  ((*oprnds_info)[i+1]->first_dt, dts[i])))))
-               {
-                 if (dump_enabled_p ())
-                   dump_printf_loc (MSG_NOTE, vect_location,
-                                    "trying swapped operands\n");
-                 std::swap (dts[i], dts[i+1]);
-                 std::swap ((*oprnds_info)[i]->def_stmts[stmt_num],
-                            (*oprnds_info)[i+1]->def_stmts[stmt_num]);
-                 std::swap ((*oprnds_info)[i]->ops[stmt_num],
-                            (*oprnds_info)[i+1]->ops[stmt_num]);
-                 swapped = true;
-                 continue;
-               }
-
-             if (is_a <bb_vec_info> (vinfo))
-               {
-                 /* Now for commutative ops we should see whether we can
-                    make the other operand matching.  */
-                 if (dump_enabled_p ())
-                   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                                    "treating operand as external\n");
-                 oprnd_info->first_dt = dt = vect_external_def;
-               }
-             else
-               {
-                 if (dump_enabled_p ())
-                   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                                    "Build SLP failed: different types\n");
-                 return 1;
-               }
+             /* Now for commutative ops we should see whether we can
+                make the other operand matching.  */
+             if (dump_enabled_p ())
+               dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                "treating operand as external\n");
+             oprnd_info->first_dt = dt = vect_external_def;
+           }
+         else
+           {
+             if (dump_enabled_p ())
+               dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                "Build SLP failed: different types\n");
+             return 1;
            }
+       }
 
       /* Make sure to demote the overall operand to external.  */
       if (dt == vect_external_def)