diff options
author | Richard Biener <rguenther@suse.de> | 2020-05-05 11:00:09 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-05-05 12:35:05 +0200 |
commit | 0424a5ece5307cc22bbc0fe97edf4707d7a798ed (patch) | |
tree | 8aa71eb224c9168fd0e7165b7256c4359f848e52 /gcc/tree-ssa-loop-im.c | |
parent | 1bd3a8af85356e64ec27309dba7fb2fca2343ffe (diff) | |
download | gcc-0424a5ece5307cc22bbc0fe97edf4707d7a798ed.zip gcc-0424a5ece5307cc22bbc0fe97edf4707d7a798ed.tar.gz gcc-0424a5ece5307cc22bbc0fe97edf4707d7a798ed.tar.bz2 |
tree-optimization/94949 - fix load eliding in SM
This fixes the case of not using the multithreaded model when
only conditionally storing to the destination. We cannot elide
the load in this case.
2020-05-05 Richard Biener <rguenther@suse.de>
PR tree-optimization/94949
* tree-ssa-loop-im.c (execute_sm): Check whether we use
the multithreaded model or always compute the stored value
before eliding a load.
* gcc.dg/torture/pr94949.c: New testcase.
Diffstat (limited to 'gcc/tree-ssa-loop-im.c')
-rw-r--r-- | gcc/tree-ssa-loop-im.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index 18e5c18..554dd4b 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -2128,9 +2128,9 @@ execute_sm (class loop *loop, vec<edge> exits, im_mem_ref *ref) fmt_data.orig_loop = loop; for_each_index (&ref->mem.ref, force_move_till, &fmt_data); + bool always_stored = ref_always_accessed_p (loop, ref, true); if (bb_in_transaction (loop_preheader_edge (loop)->src) - || (! flag_store_data_races - && ! ref_always_accessed_p (loop, ref, true))) + || (! flag_store_data_races && ! always_stored)) multi_threaded_model_p = true; if (multi_threaded_model_p) @@ -2145,8 +2145,10 @@ execute_sm (class loop *loop, vec<edge> exits, im_mem_ref *ref) /* Avoid doing a load if there was no load of the ref in the loop. Esp. when the ref is not always stored we cannot optimize it - away later. */ - if (ref->loaded && bitmap_bit_p (ref->loaded, loop->num)) + away later. But when it is not always stored we must use a conditional + store then. */ + if ((!always_stored && !multi_threaded_model_p) + || (ref->loaded && bitmap_bit_p (ref->loaded, loop->num))) { load = gimple_build_assign (tmp_var, unshare_expr (ref->mem.ref)); lim_data = init_lim_data (load); |