]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/104515 - store motion and clobbers
authorRichard Biener <rguenther@suse.de>
Wed, 17 Jul 2024 08:22:47 +0000 (10:22 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 18 Jul 2024 07:43:52 +0000 (09:43 +0200)
commit8c67dc40459e3d72e8169b099cc8c5dbdb759da3
tree9f31a22e983e39d75d6c3986d220391cd5e0620e
parent030186cabe8128e752619e101768cf8823a42c38
tree-optimization/104515 - store motion and clobbers

The following addresses an old regression when end-of-object/storage
clobbers were introduced.  In particular when there's an end-of-object
clobber in a loop but no corresponding begin-of-object we can still
perform store motion of may-aliased refs when we re-issue the
end-of-object/storage on the exits but elide it from the loop.  This
should be the safest way to deal with this considering stack-slot
sharing and it should not cause missed dead store eliminations given
DSE can now follow multiple paths in case there are multiple exits.

Note when the clobber is re-materialized only on one exit but not
on anther we are erroring on the side of removing the clobber on
such path.  This should be OK (removing clobbers is always OK).

Note there's no corresponding code to handle begin-of-object/storage
during the hoisting part of loads that are part of a store motion
optimization, so this only enables stored-only store motion or cases
without such clobber inside the loop.

PR tree-optimization/104515
* tree-ssa-loop-im.cc (execute_sm_exit): Add clobbers_to_prune
parameter and handle re-materializing of clobbers.
(sm_seq_valid_bb): end-of-storage/object clobbers are OK inside
an ordered sequence of stores.
(sm_seq_push_down): Refuse to push down clobbers.
(hoist_memory_references): Prune clobbers from the loop body
we re-materialized on an exit.

* g++.dg/opt/pr104515.C: New testcase.
gcc/testsuite/g++.dg/opt/pr104515.C [new file with mode: 0644]
gcc/tree-ssa-loop-im.cc