From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2F4F93858D37; Thu, 20 Jan 2022 15:49:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F4F93858D37 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/102478] [9/10/11/12 Regression] during RTL pass: ce3: ICE: in gen_reg_rtx, at emit-rtl.c:1167 with -O2 -fno-if-conversion Date: Thu, 20 Jan 2022 15:49:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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, 20 Jan 2022 15:49:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102478 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aoliva at gcc dot gnu.org, | |jakub at gcc dot gnu.org, | |krebbel at gcc dot gnu.org --- Comment #2 from Jakub Jelinek --- Started with r9-2592-g62852194225ed2df31ff6a600659e5cefbb1e8c0 on this testcase. But changing the testcase to: unsigned a, b, c; void foo (void) { if (a <=3D 65535) __builtin_trap (); b =3D 0; } again with -O2 -fno-if-conversion it ICEs even earlier, with my r7-6861-gada61c3d4774b98d42b53e99836abd695969fbc6 change. And with unsigned a, b; void foo (void) { if (a > 65535) b =3D 0; else __builtin_trap (); } it started even much earlier than that (before svn r200000). Seems to be similar to PR103028 where Andreas was already suggesting what y= ou suggest here. Changing those prepare_cmp_insn: /* If we are optimizing, force expensive constants into a register. */ if (CONSTANT_P (x) && optimize && (rtx_cost (x, mode, COMPARE, 0, optimize_insn_for_speed_p ()) > COSTS_N_INSNS (1))) x =3D force_reg (mode, x); if (CONSTANT_P (y) && optimize && (rtx_cost (y, mode, COMPARE, 1, optimize_insn_for_speed_p ()) > COSTS_N_INSNS (1))) y =3D force_reg (mode, y); which are purely an optimization to add && !reload_completed after && optimize would work too, the question is what other force_reg/copy_to_reg calls in prepare_cmp_insn could be a problem. The BLKmode case certainly, the VOIDmode case as well (but both of those shouldn't trigger for the cond_trap cases, then there is if (cfun->can_throw_non_call_exceptions) { if (may_trap_p (x)) x =3D copy_to_reg (x); if (may_trap_p (y)) y =3D copy_to_reg (y); } not really sure about that one.=