From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AB8763858430; Tue, 15 Feb 2022 18:10:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB8763858430 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/100874] [12 Regression] slight missed optimization with min-CST on aarch64 (subs_compare_2.c) Date: Tue, 15 Feb 2022 18:10:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization, testsuite-fail X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit 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: 12.0 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: Tue, 15 Feb 2022 18:10:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100874 --- Comment #4 from CVS Commits --- The trunk branch has been updated by Richard Sandiford : https://gcc.gnu.org/g:8e84b2b37a541b27feea69769fc314d534464ebd commit r12-7249-g8e84b2b37a541b27feea69769fc314d534464ebd Author: Richard Sandiford Date: Tue Feb 15 18:09:35 2022 +0000 aarch64: Fix subs_compare_2.c regression [PR100874] subs_compare_2.c tests that we can use a SUBS+CSEL sequence for: unsigned int foo (unsigned int a, unsigned int b) { unsigned int x =3D a - 4; if (a < 4) return x; else return 0; } As Andrew notes in the PR, this is effectively MIN (x, 4) - 4, and it is now recognised as such by phiopt. Previously it was if-converted in RTL instead. I tried to look for ways to generalise this to other situations and to other ?:-style operations, not just max and min. However, for general ?: we tend to push an outer =C3=A2- CST=C3=A2 into the arms= of the ?: -- at least if one of them simplifies -- so I didn't find any useful abstraction. This patch therefore adds a pattern specifically for max/min(a,cst)-cst. I'm not thrilled at having to do this, but it seems like the least worst fix in the circumstances. Also, max(a,cst)-cst for unsigned a is a useful saturating subtraction idiom and so is arguably worth its own code for that reason. gcc/ PR target/100874 * config/aarch64/aarch64-protos.h (aarch64_maxmin_plus_const): Declare. * config/aarch64/aarch64.cc (aarch64_maxmin_plus_const): New function. * config/aarch64/aarch64.md (*aarch64_minmax_plus): New pattern. gcc/testsuite/ * gcc.target/aarch64/max_plus_1.c: New test. * gcc.target/aarch64/max_plus_2.c: Likewise. * gcc.target/aarch64/max_plus_3.c: Likewise. * gcc.target/aarch64/max_plus_4.c: Likewise. * gcc.target/aarch64/max_plus_5.c: Likewise. * gcc.target/aarch64/max_plus_6.c: Likewise. * gcc.target/aarch64/max_plus_7.c: Likewise. * gcc.target/aarch64/min_plus_1.c: Likewise. * gcc.target/aarch64/min_plus_2.c: Likewise. * gcc.target/aarch64/min_plus_3.c: Likewise. * gcc.target/aarch64/min_plus_4.c: Likewise. * gcc.target/aarch64/min_plus_5.c: Likewise. * gcc.target/aarch64/min_plus_6.c: Likewise. * gcc.target/aarch64/min_plus_7.c: Likewise.=