public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/101256] New: [12 Regression] Wrong code with -O3 since r12-1841-g9fe9c45ae33a2df7
@ 2021-06-29 11:18 marxin at gcc dot gnu.org
  2021-06-29 11:18 ` [Bug tree-optimization/101256] " marxin at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-06-29 11:18 UTC (permalink / raw)
  To: gcc-bugs

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)

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-07-06  7:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29 11:18 [Bug tree-optimization/101256] New: [12 Regression] Wrong code with -O3 since r12-1841-g9fe9c45ae33a2df7 marxin at gcc dot gnu.org
2021-06-29 11:18 ` [Bug tree-optimization/101256] " marxin at gcc dot gnu.org
2021-06-29 12:05 ` rguenth at gcc dot gnu.org
2021-06-29 17:28 ` pinskia at gcc dot gnu.org
2021-06-29 20:39 ` pinskia at gcc dot gnu.org
2021-06-30  0:37 ` pinskia at gcc dot gnu.org
2021-07-02  6:56 ` marxin at gcc dot gnu.org
2021-07-02  7:03 ` marxin at gcc dot gnu.org
2021-07-02 20:10 ` pinskia at gcc dot gnu.org
2021-07-06  1:34 ` pinskia at gcc dot gnu.org
2021-07-06  7:34 ` cvs-commit at gcc dot gnu.org
2021-07-06  7:35 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).