diff options
author | Richard Biener <rguenther@suse.de> | 2020-05-22 09:03:40 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-05-22 13:08:44 +0200 |
commit | 7c592aad23c22b9f888837020cd0a7475d8f3938 (patch) | |
tree | d47c1442833949cabfd9859b60558c08db162065 /gcc/tree-ssa-sink.c | |
parent | 1089a367c4b05b5e3f072adca8913904ed65928c (diff) | |
download | gcc-7c592aad23c22b9f888837020cd0a7475d8f3938.zip gcc-7c592aad23c22b9f888837020cd0a7475d8f3938.tar.gz gcc-7c592aad23c22b9f888837020cd0a7475d8f3938.tar.bz2 |
tree-optimization/95268 - fix commoning of clobbers
This fixes handling of clobbers when commoning stores.
2020-05-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/95268
* tree-ssa-sink.c (sink_common_stores_to_bb): Handle clobbers
properly.
* g++.dg/torture/pr95268.C: New testcase.
Diffstat (limited to 'gcc/tree-ssa-sink.c')
-rw-r--r-- | gcc/tree-ssa-sink.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c index c5b535be..b61ecf1 100644 --- a/gcc/tree-ssa-sink.c +++ b/gcc/tree-ssa-sink.c @@ -534,7 +534,9 @@ sink_common_stores_to_bb (basic_block bb) /* ??? We could handle differing SSA uses in the LHS by inserting PHIs for them. */ else if (! operand_equal_p (gimple_assign_lhs (first_store), - gimple_assign_lhs (def), 0)) + gimple_assign_lhs (def), 0) + || (gimple_clobber_p (first_store) + && !gimple_clobber_p (def))) { first_store = NULL; break; @@ -546,16 +548,17 @@ sink_common_stores_to_bb (basic_block bb) /* Check if we need a PHI node to merge the stored values. */ bool allsame = true; - for (unsigned i = 1; i < vdefs.length (); ++i) - { - gimple *def = SSA_NAME_DEF_STMT (vdefs[i]); - if (! operand_equal_p (gimple_assign_rhs1 (first_store), - gimple_assign_rhs1 (def), 0)) - { - allsame = false; - break; - } - } + if (!gimple_clobber_p (first_store)) + for (unsigned i = 1; i < vdefs.length (); ++i) + { + gimple *def = SSA_NAME_DEF_STMT (vdefs[i]); + if (! operand_equal_p (gimple_assign_rhs1 (first_store), + gimple_assign_rhs1 (def), 0)) + { + allsame = false; + break; + } + } /* We cannot handle aggregate values if we need to merge them. */ tree type = TREE_TYPE (gimple_assign_lhs (first_store)); |