https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101256
Bug ID: 101256 Summary: [12 Regression] Wrong code with -O3 since r12-1841-g9fe9c45ae33a2df7 Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org CC: pinskia at gcc dot gnu.org Target Milestone: --- Created attachment 51081 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51081&action=edit test-case It's a yarpgen test case and it's not easily reducible. However, with the following patch: diff --git a/gcc/dbgcnt.def b/gcc/dbgcnt.def index 93e7b4fd30e..6186b5533ca 100644 --- a/gcc/dbgcnt.def +++ b/gcc/dbgcnt.def @@ -158,6 +158,7 @@ DEBUG_COUNTER (dom_unreachable_edges) DEBUG_COUNTER (dse) DEBUG_COUNTER (dse1) DEBUG_COUNTER (dse2) +DEBUG_COUNTER (edge_range) DEBUG_COUNTER (gcse2_delete) DEBUG_COUNTER (gimple_unroll) DEBUG_COUNTER (global_alloc_at_func) diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index ab12e85569d..21741504038 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-fold.h" #include "internal-fn.h" #include "gimple-range.h" +#include "dbgcnt.h" static unsigned int tree_ssa_phiopt_worker (bool, bool, bool); static bool two_value_replacement (basic_block, basic_block, edge, gphi *, @@ -413,7 +414,8 @@ replace_phi_edge_with_variable (basic_block cond_block, && EDGE_COUNT (gimple_bb (phi)->preds) == 2 && INTEGRAL_TYPE_P (TREE_TYPE (phi_result)) && !SSA_NAME_RANGE_INFO (new_tree) - && SSA_NAME_RANGE_INFO (phi_result)) + && SSA_NAME_RANGE_INFO (phi_result) + && dbg_cnt(edge_range)) duplicate_ssa_name_range_info (new_tree, SSA_NAME_RANGE_TYPE (phi_result), SSA_NAME_RANGE_INFO (phi_result)); One can reduce it to: $ g++ driver.cpp -c && g++ func.cpp -O3 -c -fdbg-cnt=edge_range:52-52 && gcc func.o driver.o && ./a.out ***dbgcnt: lower limit 52 reached for edge_range.*** ***dbgcnt: upper limit 52 reached for edge_range.*** a.out: driver.cpp:3609: void checksum(): Assertion `var_303 == (unsigned char)240' failed. Aborted (core dumped)