From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 726B53858414; Wed, 13 Sep 2023 16:39:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 726B53858414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694623177; bh=OL4K6Rd2qo4OrxNwYaxn9ukRBMbWpLRU2svK4+k+nWo=; h=From:To:Subject:Date:From; b=ruSXgIIqvsTXwIu6ZvhyFSCbcKXEn9hSYY3pTq50UsPRAy75vGKRiD1Fsua5JhnKy HDbMnwF//eQLFM1a2JAViHFennRUf4rTG2xDlQnt1QTKBtxV7xznzmp/yMzy/mrNvI pw0OkXh8IKFUxr/KLi8Dqkabhq9/3Czhxhcbrx+Q= From: "qinzhao at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111407] New: ICE: SSA corruption due to widening_mul opt on conflict across an abnormal edge Date: Wed, 13 Sep 2023 16:39:34 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: qinzhao at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111407 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.=20 there were multiple similar failures due to this issue for our large application.=20 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,=20 The compiler needs to check whether the operand is in a ABNORMAL PHI, if YE= S, 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.9623365= 30 +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. */=20 + if ((TREE_CODE (rhs1) =3D=3D SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)) + || (TREE_CODE (rhs2) =3D=3D SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs2))) + return false; + to_mode =3D SCALAR_INT_TYPE_MODE (type); from_mode =3D SCALAR_INT_TYPE_MODE (type1); if (to_mode =3D=3D 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.=