diff options
author | Richard Biener <rguenther@suse.de> | 2024-08-21 13:56:40 +0200 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2024-08-21 14:47:53 +0200 |
commit | af0d2d95a5f767d92bd64f959679fb4612247b0b (patch) | |
tree | 5688e1bbfd328af9a9efc0d0bb95acf0644aacf6 /gcc | |
parent | fd7dabc116b9abc40ee6aa25bcc5d240b8cc516a (diff) | |
download | gcc-af0d2d95a5f767d92bd64f959679fb4612247b0b.zip gcc-af0d2d95a5f767d92bd64f959679fb4612247b0b.tar.gz gcc-af0d2d95a5f767d92bd64f959679fb4612247b0b.tar.bz2 |
tree-optimization/116380 - bogus SSA update with loop distribution
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr116380.c | 16 | ||||
-rw-r--r-- | gcc/tree-loop-distribution.cc | 3 |
2 files changed, 19 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr116380.c b/gcc/testsuite/gcc.dg/torture/pr116380.c new file mode 100644 index 0000000..5ffd994 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr116380.c @@ -0,0 +1,16 @@ +/* { 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; +} diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc index f87393e..10f261a 100644 --- a/gcc/tree-loop-distribution.cc +++ b/gcc/tree-loop-distribution.cc @@ -980,6 +980,9 @@ copy_loop_before (class loop *loop, bool redirect_lc_phi_defs) 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); } } |