https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82604

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
failed loop-distribution hack:  (still needs dependence analysis fixes)
Could even preserve TBAA if we use a {} of correct element array type.
For constant sizes this should be always a win.

Index: gcc/tree-loop-distribution.c
===================================================================
--- gcc/tree-loop-distribution.c        (revision 254858)
+++ gcc/tree-loop-distribution.c        (working copy)
@@ -1006,9 +1006,22 @@ generate_memset_builtin (struct loop *lo
       val = tem;
     }

-  fn = build_fold_addr_expr (builtin_decl_implicit (BUILT_IN_MEMSET));
-  fn_call = gimple_build_call (fn, 3, mem, val, nb_bytes);
-  gsi_insert_after (&gsi, fn_call, GSI_CONTINUE_LINKING);
+  if (! integer_zerop (val))
+    {
+      fn = build_fold_addr_expr (builtin_decl_implicit (BUILT_IN_MEMSET));
+      fn_call = gimple_build_call (fn, 3, mem, val, nb_bytes);
+      gsi_insert_after (&gsi, fn_call, GSI_CONTINUE_LINKING);
+    }
+  else
+    {
+      tree arrt = build_array_type (char_type_node, NULL_TREE);
+      gassign *ass = gimple_build_assign (build2 (MEM_REF, arrt,
+                                                 mem, build_zero_cst
(ptr_type_node)),
+                                         build2 (WITH_SIZE_EXPR, arrt,
+                                                 build_constructor (arrt,
NULL),
+                                                 nb_bytes));
+      gsi_insert_after (&gsi, ass, GSI_CONTINUE_LINKING);
+    }

   if (dump_file && (dump_flags & TDF_DETAILS))
     {

Reply via email to