When updating LC PHIs after copying loops we have to handle defs
defined outside of the loop appropriately (by not setting them to
NULL ...). This mimics how we handle this in the SSA updating
code of the vectorizer.
PR tree-optimization/116380
* tree-loop-distribution.cc (copy_loop_before): Handle
out-of-loop defs appropriately.
* gcc.dg/torture/pr116380.c: New testcase.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-tree-scev-cprop" } */
+
+int a[3], d[3], c;
+int f(int e, int b)
+{
+ for (; e < 3; e++)
+ {
+ a[0] = 0;
+ if (b)
+ c = b;
+ d[e] = 0;
+ a[e] = 0;
+ }
+ return e;
+}
if (TREE_CODE (USE_FROM_PTR (use_p)) == SSA_NAME)
{
tree new_def = get_current_def (USE_FROM_PTR (use_p));
+ if (!new_def)
+ /* Something defined outside of the loop. */
+ continue;
SET_USE (use_p, new_def);
}
}