From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CA1D83858C36; Thu, 7 Mar 2024 17:20:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA1D83858C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709832053; bh=sDWFx6EuQzPKqUeR2pk9aLPEgKsYFbKNyVC6xj/kJ+o=; h=From:To:Subject:Date:From; b=NuUBnt75AbfKcAWnne3mdaNQuRO+JkZCsMyMYmrgAu/fXILbieIgiVR9+KjsaUZ5A Qk2zVcFIiVOOZ6O/RHWJ7cjAvmGPiasuIVKxCbQgvBoYo9HP12AL3QfHhalj1RbGcM UVXAr+whlLMH4ZdkmOAU8jOOTiPfBQhZRDgsqllU= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114273] New: `PHI(a, MIN(b, c)) < c` is not optimized to just `PHI(a,b) < c` Date: Thu, 07 Mar 2024 17:20:53 +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: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia 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 keywords 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=3D114273 Bug ID: 114273 Summary: `PHI(a, MIN(b, c)) < c` is not optimized to just `PHI(a,b) < c` Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` void dummy(void); bool f(unsigned a, unsigned b, bool c) { unsigned ind =3D b; if (c) { dummy(); ind =3D a > 6 ? 6 : a; } return ind < 6; } bool f2(unsigned a, unsigned b, bool c) { unsigned ind =3D b; if (c) { dummy(); ind =3D a; } return ind < 6; } ``` GCC should be able to remove the MIN_EXPR in f. Note GCC is able to optimize `MIN_EXPR < b` since r14-3922-g06bedc3860d3e6 . This seems like PRE is the place for this kind of optimization but I am not 100% sure.=