Move code that stubs out IFN_MASK_LOADs
authorRichard Sandiford <richard.sandiford@linaro.org>
Wed, 3 Jan 2018 21:46:45 +0000 (21:46 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Wed, 3 Jan 2018 21:46:45 +0000 (21:46 +0000)
vectorizable_mask_load_store replaces scalar IFN_MASK_LOAD calls with
dummy assignments, so that they never survive vectorisation.  This patch
moves the code to vect_transform_loop instead, so that we only change
the scalar statements once all of them have been vectorised.

This makes it easier to handle other types of functions that need
stubbing out, and also makes it easier to handle groups and patterns.

2018-01-03  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
* tree-vect-loop.c (vect_transform_loop): Stub out scalar
IFN_MASK_LOAD calls here rather than...
* tree-vect-stmts.c (vectorizable_mask_load_store): ...here.

From-SVN: r256210

gcc/ChangeLog
gcc/tree-vect-loop.c
gcc/tree-vect-stmts.c

index 5dbf3ba55249bf8356ba2ae274f642b13523cff8..309c00942bfd5bfa3625f4bc67d712caa57dcebf 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-03  Richard Sandiford  <richard.sandiford@linaro.org>
+
+       * tree-vect-loop.c (vect_transform_loop): Stub out scalar
+       IFN_MASK_LOAD calls here rather than...
+       * tree-vect-stmts.c (vectorizable_mask_load_store): ...here.
+
 2018-01-03  Richard Sandiford  <richard.sandiford@linaro.org>
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
index 2fd11df6c09e1d55de146d5c59722fca6dc054cc..c2501a8407ca8b33e6bda76db1d1b6d643062526 100644 (file)
@@ -7810,6 +7810,25 @@ vect_transform_loop (loop_vec_info loop_vinfo)
              gsi_next (&si);
            }
        }                       /* stmts in BB */
+
+      /* Stub out scalar statements that must not survive vectorization.
+        Doing this here helps with grouped statements, or statements that
+        are involved in patterns.  */
+      for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
+          !gsi_end_p (gsi); gsi_next (&gsi))
+       {
+         gcall *call = dyn_cast <gcall *> (gsi_stmt (gsi));
+         if (call && gimple_call_internal_p (call, IFN_MASK_LOAD))
+           {
+             tree lhs = gimple_get_lhs (call);
+             if (!VECTOR_TYPE_P (TREE_TYPE (lhs)))
+               {
+                 tree zero = build_zero_cst (TREE_TYPE (lhs));
+                 gimple *new_stmt = gimple_build_assign (lhs, zero);
+                 gsi_replace (&gsi, new_stmt, true);
+               }
+           }
+       }
     }                          /* BBs in loop */
 
   /* The vectorization factor is always > 1, so if we use an IV increment of 1.
index 27a8f7bb7ae11310e85a29f8a8ee1f5154f49602..96c6605d9591856ce98033c7b8f2ca12663bc59c 100644 (file)
@@ -2347,20 +2347,6 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
            STMT_VINFO_RELATED_STMT (prev_stmt_info) = new_stmt;
          prev_stmt_info = vinfo_for_stmt (new_stmt);
        }
-
-      /* Ensure that even with -fno-tree-dce the scalar MASK_LOAD is removed
-        from the IL.  */
-      if (STMT_VINFO_RELATED_STMT (stmt_info))
-       {
-         stmt = STMT_VINFO_RELATED_STMT (stmt_info);
-         stmt_info = vinfo_for_stmt (stmt);
-       }
-      tree lhs = gimple_call_lhs (stmt);
-      new_stmt = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs)));
-      set_vinfo_for_stmt (new_stmt, stmt_info);
-      set_vinfo_for_stmt (stmt, NULL);
-      STMT_VINFO_STMT (stmt_info) = new_stmt;
-      gsi_replace (gsi, new_stmt, true);
       return true;
     }
   else if (vls_type != VLS_LOAD)
@@ -2477,23 +2463,6 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
        }
     }
 
-  if (vls_type == VLS_LOAD)
-    {
-      /* Ensure that even with -fno-tree-dce the scalar MASK_LOAD is removed
-        from the IL.  */
-      if (STMT_VINFO_RELATED_STMT (stmt_info))
-       {
-         stmt = STMT_VINFO_RELATED_STMT (stmt_info);
-         stmt_info = vinfo_for_stmt (stmt);
-       }
-      tree lhs = gimple_call_lhs (stmt);
-      new_stmt = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs)));
-      set_vinfo_for_stmt (new_stmt, stmt_info);
-      set_vinfo_for_stmt (stmt, NULL);
-      STMT_VINFO_STMT (stmt_info) = new_stmt;
-      gsi_replace (gsi, new_stmt, true);
-    }
-
   return true;
 }