public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111407] New: ICE: SSA corruption due to widening_mul opt on conflict across an abnormal edge
@ 2023-09-13 16:39 qinzhao at gcc dot gnu.org
  2023-09-13 17:02 ` [Bug tree-optimization/111407] " pinskia at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2023-09-13 16:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111407

            Bug ID: 111407
           Summary: ICE: SSA corruption due to widening_mul opt on
                    conflict across an abnormal edge
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qinzhao at gcc dot gnu.org
  Target Milestone: ---

this bug was originally reported against GCC8.5 with profiling feedback. 
there were multiple similar failures due to this issue for our large
application. 

Although we reduced the testing case to a very small size, and changed the
variable names. the failure can only be repeated with -fprofile-use and the
.gcda files. As a result, we cannot expose the testing case.

With the small testing case, and debugging into GCC8, I finally locate the
issue is:

this is a bug in tree-ssa-math-opts.cc, when applying the widening mul
optimization, 
The compiler needs to check whether the operand is in a ABNORMAL PHI, if YES,
we should avoid the transformation.

the following patch against GCC8 can fix the failure very well:

diff -u -r -N -p gcc-8.5.0-20210514-org/gcc/tree-ssa-math-opts.c
gcc-8.5.0-20210514/gcc/tree-ssa-math-opts.c
--- gcc-8.5.0-20210514-org/gcc/tree-ssa-math-opts.c 2023-09-11
21:04:17.891403319 +0000
+++ gcc-8.5.0-20210514/gcc/tree-ssa-math-opts.c 2023-09-13 15:35:44.962336530
+0000
@@ -2346,6 +2346,14 @@ convert_mult_to_widen (gimple *stmt, gim
if (!is_widening_mult_p (stmt, &type1, &rhs1, &type2, &rhs2))
return false;

+ /* if any one of rhs1 and rhs2 is subjust to abnormal coalescing
+ * avoid the tranform. */ 
+ if ((TREE_CODE (rhs1) == SSA_NAME
+ && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1))
+ || (TREE_CODE (rhs2) == SSA_NAME
+ && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs2)))
+ return false;
+
to_mode = SCALAR_INT_TYPE_MODE (type);
from_mode = SCALAR_INT_TYPE_MODE (type1);
if (to_mode == from_mode)

I checked the latest upstream GCC14, and found that the function
"convert_mult_to_widen" has the same issue, need to be patched as well.

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

end of thread, other threads:[~2024-04-02 16:56 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-13 16:39 [Bug tree-optimization/111407] New: ICE: SSA corruption due to widening_mul opt on conflict across an abnormal edge qinzhao at gcc dot gnu.org
2023-09-13 17:02 ` [Bug tree-optimization/111407] " pinskia at gcc dot gnu.org
2023-09-13 17:04 ` pinskia at gcc dot gnu.org
2023-09-13 17:05 ` qinzhao at gcc dot gnu.org
2023-09-13 17:06 ` qinzhao at gcc dot gnu.org
2023-09-13 17:14 ` pinskia at gcc dot gnu.org
2023-09-13 17:26 ` pinskia at gcc dot gnu.org
2023-09-13 18:19 ` qinzhao at gcc dot gnu.org
2023-09-13 18:52 ` qinzhao at gcc dot gnu.org
2023-09-15 13:47 ` cvs-commit at gcc dot gnu.org
2023-09-15 13:56 ` qinzhao at gcc dot gnu.org
2024-02-29  7:36 ` [Bug tree-optimization/111407] [11/12/13 Regression] " pinskia at gcc dot gnu.org
2024-02-29  7:37 ` pinskia at gcc dot gnu.org
2024-02-29 14:43 ` qinzhao at gcc dot gnu.org
2024-04-02 14:50 ` cvs-commit at gcc dot gnu.org
2024-04-02 15:56 ` cvs-commit at gcc dot gnu.org
2024-04-02 16:54 ` cvs-commit at gcc dot gnu.org
2024-04-02 16:56 ` qinzhao 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).