tree-optimization/39612 - avoid issueing loads in SM when possible
authorRichard Biener <rguenther@suse.de>
Thu, 30 Apr 2020 08:47:15 +0000 (10:47 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 4 May 2020 12:14:36 +0000 (14:14 +0200)
commitf9e1ea10e657af9fb02fafecf1a600740fd34409
tree3bbed9af6d91c30c5e64d64f17aa58214c377f97
parent375a77925c320a273d3b1ef3182f29f31aaa8edf
tree-optimization/39612 - avoid issueing loads in SM when possible

Currently store-motion emits a load of the value in the loop
preheader even when the original loop does not contain any read
of the reference.  This avoids doing this.  In the conditional
store-motion case we need to mark the sunk stores with no-warning
since the control dependence is too tricky to figure out for
the uninit warning.

2020-05-04  Richard Biener  <rguenther@suse.de>

PR tree-optimization/39612
* tree-ssa-loop-im.c (im_mem_ref::loaded): New member.
(set_ref_loaded_in_loop): New.
(mark_ref_loaded): Likewise.
(gather_mem_refs_stmt): Call mark_ref_loaded for loads.
(execute_sm): Avoid issueing a load when it was not there.
(execute_sm_if_changed): Avoid issueing warnings for the
conditional store.

* gcc.dg/tree-ssa/pr39612.c: New testcase.
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr39612.c [new file with mode: 0644]
gcc/tree-ssa-loop-im.c