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.