From: Richard Biener Date: Fri, 22 May 2020 07:03:40 +0000 (+0200) Subject: tree-optimization/95268 - fix commoning of clobbers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7c592aad23c22b9f888837020cd0a7475d8f3938;p=gcc.git tree-optimization/95268 - fix commoning of clobbers This fixes handling of clobbers when commoning stores. 2020-05-22 Richard Biener PR tree-optimization/95268 * tree-ssa-sink.c (sink_common_stores_to_bb): Handle clobbers properly. * g++.dg/torture/pr95268.C: New testcase. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d22e9aa250e..b0ba14b3305 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-05-22 Richard Biener + + PR tree-optimization/95268 + * tree-ssa-sink.c (sink_common_stores_to_bb): Handle clobbers + properly. + 2020-05-22 Jan Hubicka * tree-streamer.c (record_common_node): Fix hash value of pre-streamed diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1e8ad06f78a..5a628260925 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-05-22 Richard Biener + + PR tree-optimization/95268 + * g++.dg/torture/pr95268.C: New testcase. + 2020-05-22 Richard Biener PR tree-optimization/95248 diff --git a/gcc/testsuite/g++.dg/torture/pr95268.C b/gcc/testsuite/g++.dg/torture/pr95268.C new file mode 100644 index 00000000000..8385b86e179 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr95268.C @@ -0,0 +1,46 @@ +// { dg-do compile } +// { dg-require-effective-target lp64 } +// { dg-additional-options "-Wno-overflow" } + +#include + +extern short var_0, var_2, var_3, var_9, var_11, var_13, var_14, var_19, var_22, + var_32, var_37, var_44, var_57, var_59, var_63, var_70; +extern unsigned var_5; +extern char var_6, var_12, var_18, var_38, var_39, var_43, var_55, var_64, + arr_35; +extern long var_7, var_8, var_10, var_15, var_25, var_56; +extern int var_21, var_36, var_51, var_65, var_68, arr_7; +extern bool var_46, var_58, var_67; + +void test() { + var_12 = 0 >= 0; + var_13 = arr_7; + var_14 = (unsigned long)var_7 >> -564810131 + 564810189; + var_15 = var_5; + var_18 = -602739307623583391; + var_19 = -~0; + var_21 = var_10 >> var_8 - 17101301574577641170ULL; + var_22 = var_5; + var_25 = var_9; + var_32 = std::max((unsigned)var_2, var_5); + var_36 = 9557; + var_37 = 394545925; + var_38 = 0 >= 0; + var_39 = var_5; + var_43 = 0; + var_44 = arr_35; + var_46 = var_7; + for (short a = 0; a < 9; a = 021) + for (short b = 0; b < 024; b += 4) + var_51 = std::min((long long)(var_2 ?: var_9), (long long)var_9); + var_55 = var_0; + var_56 = 3896150587; + var_57 = var_11; + var_58 = var_59 = var_11; + var_63 = 73; + var_64 = 10393232284806619711ULL; + var_65 = var_3; + var_67 = var_6; + var_68 = var_70 = 0; +} diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c index c5b535bed4d..b61ecf12d1f 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));