tree-optimization/112310 - code hoisting undefined behavior
commit2266f7cbc78dfcf7c0739466644e0a6b9966553c
authorRichard Biener <rguenther@suse.de>
Fri, 3 Nov 2023 09:45:18 +0000 (3 10:45 +0100)
committerRichard Biener <rguenther@suse.de>
Fri, 3 Nov 2023 10:35:03 +0000 (3 11:35 +0100)
treea0794f051d306cb29cad39cac5fc3d569f4bfb57
parent8c8ad4e3533b8590ce063386b8b32f6fce1c3942
tree-optimization/112310 - code hoisting undefined behavior

The following avoids hoisting expressions that may invoke undefined
behavior and are not computed on all paths.  This is realized by
noting that we have to avoid materializing expressions as part
of hoisting that are not part of the set of expressions we have
found eligible for hoisting.  Instead of picking the expression
corresponding to the hoistable values from the first successor
we now keep a union of the expressions so that hoisting can pick
the expression that has its dependences fully hoistable.

PR tree-optimization/112310
* tree-ssa-pre.cc (do_hoist_insertion): Keep the union
of expressions, validate dependences are contained within
the hoistable set before hoisting.

* gcc.dg/torture/pr112310.c: New testcase.
gcc/testsuite/gcc.dg/torture/pr112310.c [new file with mode: 0644]
gcc/tree-ssa-pre.cc