]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/112305 - SCEV cprop and conditional undefined overflow
authorRichard Biener <rguenther@suse.de>
Tue, 31 Oct 2023 09:13:13 +0000 (10:13 +0100)
committerRichard Biener <rguenther@suse.de>
Tue, 31 Oct 2023 12:10:04 +0000 (13:10 +0100)
commite3da1d7bb288c8c864f0284bc4bc5877b466a2f7
tree62538be0a67da1b32b62660c4977d05a7da05c4d
parent1cf5dc05c678232b52ac0572a94b891131ef48f0
tree-optimization/112305 - SCEV cprop and conditional undefined overflow

The following adjusts final value replacement to also rewrite the
replacement to defined overflow behavior if there's conditionally
evaluated stmts (with possibly undefined overflow), not only when
we "folded casts".  The patch hooks into expression_expensive for
this.

PR tree-optimization/112305
* tree-scalar-evolution.h (expression_expensive): Adjust.
* tree-scalar-evolution.cc (expression_expensive): Record
when we see a COND_EXPR.
(final_value_replacement_loop): When the replacement contains
a COND_EXPR, rewrite it to defined overflow.
* tree-ssa-loop-ivopts.cc (may_eliminate_iv): Adjust.

* gcc.dg/torture/pr112305.c: New testcase.
gcc/testsuite/gcc.dg/torture/pr112305.c [new file with mode: 0644]
gcc/tree-scalar-evolution.cc
gcc/tree-scalar-evolution.h
gcc/tree-ssa-loop-ivopts.cc