diff options
author | Richard Biener <rguenther@suse.de> | 2023-11-14 14:26:17 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-11-14 15:10:16 +0100 |
commit | 2066c29bf8dea87c9810eb261e342d941a6b2059 (patch) | |
tree | 34492059041d5693822be11a08626a4192d03d7e /gcc/tree-ssa-loop-split.cc | |
parent | bc390ae72ff974d6985639b5b392f6e9192c2ee7 (diff) | |
download | gcc-2066c29bf8dea87c9810eb261e342d941a6b2059.zip gcc-2066c29bf8dea87c9810eb261e342d941a6b2059.tar.gz gcc-2066c29bf8dea87c9810eb261e342d941a6b2059.tar.bz2 |
tree-optimization/111233 - loop splitting miscompile
The change in r14-2852-gf5fb9ff2396fd4 failed to update patch_loop_exit
to compensate for rewriting of a NE/EQ_EXPR to a new code. Fixed
with the following.
PR tree-optimization/111233
PR tree-optimization/111652
PR tree-optimization/111727
PR tree-optimization/111838
PR tree-optimization/112113
* tree-ssa-loop-split.cc (patch_loop_exit): Get the new
guard code instead of the old guard stmt.
(split_loop): Adjust.
* gcc.dg/torture/pr111233.c: New testcase.
* gcc.dg/torture/pr111652.c: Likewise.
* gcc.dg/torture/pr111727.c: Likewise.
* gcc.dg/torture/pr111838.c: Likewise.
* gcc.dg/torture/pr112113.c: Likewise.
Diffstat (limited to 'gcc/tree-ssa-loop-split.cc')
-rw-r--r-- | gcc/tree-ssa-loop-split.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gcc/tree-ssa-loop-split.cc b/gcc/tree-ssa-loop-split.cc index 6446480..2e2adb6 100644 --- a/gcc/tree-ssa-loop-split.cc +++ b/gcc/tree-ssa-loop-split.cc @@ -194,13 +194,12 @@ split_at_bb_p (class loop *loop, basic_block bb, tree *border, affine_iv *iv, also be true/false in the next iteration. */ static void -patch_loop_exit (class loop *loop, gcond *guard, tree nextval, tree newbound, - bool initial_true) +patch_loop_exit (class loop *loop, tree_code guard_code, tree nextval, + tree newbound, bool initial_true) { edge exit = single_exit (loop); gcond *stmt = as_a <gcond *> (*gsi_last_bb (exit->src)); - gimple_cond_set_condition (stmt, gimple_cond_code (guard), - nextval, newbound); + gimple_cond_set_condition (stmt, guard_code, nextval, newbound); update_stmt (stmt); edge stay = EDGE_SUCC (exit->src, EDGE_SUCC (exit->src, 0) == exit); @@ -745,7 +744,7 @@ split_loop (class loop *loop1) gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop1), stmts); tree guard_next = PHI_ARG_DEF_FROM_EDGE (phi, loop_latch_edge (loop1)); - patch_loop_exit (loop1, guard_stmt, guard_next, newend, initial_true); + patch_loop_exit (loop1, guard_code, guard_next, newend, initial_true); /* Finally patch out the two copies of the condition to be always true/false (or opposite). */ |