From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7BC2A3846472; Thu, 30 Jun 2022 02:21:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BC2A3846472 From: "luoxhu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106126] [12 Regression] tree check fail in useless_type_conversion_p, at gimple-expr.cc:87 since r13-1184-g57424087e82db140 Date: Thu, 30 Jun 2022 02:21:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: luoxhu at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2022 02:21:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106126 --- Comment #11 from luoxhu at gcc dot gnu.org --- Sorry for breaking, my bugzilla account is luoxhu@gcc.gnu.org. The patch seems reasonable to fold 65-90 ('A'-'Z') to switch statement,=20 4,6c4,6 < ;; Canonical GIMPLE case clusters: 33 60 62 126 < ;; BT can be built: BT(values:3 comparisons:6 range:30 density: 20.00%):3= 3-62 126 < pr106126.c:3:28: optimized: Condition chain with 4 BBs transformed into a switch statement. --- > ;; Canonical GIMPLE case clusters: 33 60 62 65-90 126 > ;; BT can be built: BT(values:3 comparisons:6 range:30 density: 20.00%):3= 3-62 65-90 126 > pr106126.c:3:28: optimized: Condition chain with 5 BBs transformed into a= switch statement. ... 96,97c108,109 < : < switch (_13) [INV], case 33: [INV], case 60: [INV], case 62: [INV], case 126: [INV]> --- > : > switch (_13) [INV], case 33: [INV], case 60: [INV], case 62: [INV], case 65 ... 90: [INV], case 126: = [INV]> complete pr106126.bad.c.046t.iftoswitch: ;; Function pool_conda_matchspec (pool_conda_matchspec, funcdef_no=3D0, decl_uid=3D1979, cgraph_uid=3D1, symbol_order=3D1) ;; Canonical GIMPLE case clusters: 33 60 62 65-90 126 ;; BT can be built: BT(values:3 comparisons:6 range:30 density: 20.00%):33-= 62 65-90 126 pr106126.c:3:28: optimized: Condition chain with 5 BBs transformed into a switch statement. Removing basic block 9 ;; basic block 9, loop depth 2 ;; pred: if (_13 !=3D 62) goto ; [INV] else goto ; [INV] ;; succ: 10 ;; 12 Removing basic block 10 ;; basic block 10, loop depth 2 ;; pred: if (_13 !=3D 33) goto ; [INV] else goto ; [INV] ;; succ: 11 ;; 12 Removing basic block 11 ;; basic block 11, loop depth 2 ;; pred: if (_13 !=3D 126) goto ; [INV] else goto ; [INV] ;; succ: 3 ;; 12 Removing basic block 3 ;; basic block 3, loop depth 2 ;; pred: _3 =3D (unsigned char) _13; _4 =3D _3 + 191; if (_4 <=3D 25) goto ; [INV] else goto ; [INV] ;; succ: 14 ;; 13 Expanded into a new gimple STMT: switch (_13) [INV], case 3= 3: [INV], case 60: [INV], case 62: [INV], case 65 ... 90: [INV], case 126: [INV]> Removing basic block 13 ;; basic block 13, loop depth 2 ;; pred: : goto ; [100.00%] ;; succ: 6 Removing basic block 14 ;; basic block 14, loop depth 1 ;; pred: : ;; succ: 4 fix_loop_structure: fixing up loops for function void pool_conda_matchspec () { unsigned char _8; char _10; char * var_1.3_11; char _13; unsigned char _14; char * var_1.3_15; : goto ; [INV] : # _14 =3D PHI <_3(7)> # var_1.3_15 =3D PHI : _8 =3D _14 + 65; _10 =3D (char) _8; *var_1.3_15 =3D _10; : : : var_1.3_11 =3D var_1; if (var_1.3_11 !=3D 0B) goto ; [INV] else goto ; [INV] : _13 =3D *var_1.3_11; if (_13 !=3D 0) goto ; [INV] else goto ; [INV] : switch (_13) [INV], case 33: [INV], case 60: [INV], case 62: [INV], case 65 ... 90: [INV], case 126: [INV]> : : return; _8 =3D _14 + 65; _10 =3D (char) _8; *var_1.3_15 =3D _10; : : : var_1.3_11 =3D var_1; if (var_1.3_11 !=3D 0B) goto ; [INV] else goto ; [INV] : _13 =3D *var_1.3_11; if (_13 !=3D 0) goto ; [INV] else goto ; [INV] : switch (_13) [INV], case 33: [INV], case 60: [INV], case 62: [INV], case 65 ... 90: [INV], case 126: [INV]> : : return; } The problem is _3 is removed in basic block 3, but _14 is still using it.=