From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 345E93937433; Mon, 16 Mar 2020 03:34:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 345E93937433 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584329663; bh=0gcrUQY9Dp59eqa3A5hKaO+orAQMEtuq1etJLTNHLhE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=udvo1JJWmaJSWgULjN51+K3T4KAWdKdU7gNUjM1pZKac1QHzk/vi90XsupXlg4hw/ r4KYvySQN9vk1LxXTemZ2lnJ+B2ene2krGnUQP8le5/Dg2Jm3aPvKoM1AntWr5H38w s7Gdc7hvU6UunxMiKA1kb1v7pmqSHkcKr7VB/Xx0= From: "felix.yang at huawei dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/94026] combine missed opportunity to simplify comparisons with zero Date: Mon, 16 Mar 2020 03:34:22 +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: 10.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: felix.yang at huawei dot com 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: 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: Mon, 16 Mar 2020 03:34:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94026 --- Comment #4 from Fei Yang --- (In reply to Fei Yang from comment #0) > Created attachment 47966 [details] > proposed patch to fix this issue >=20 > Simple test case: > int > foo (int c, int d) > { > int a =3D (c >> d) & 7; >=20 > if (a >=3D 2) { > return 1; > } >=20 > return 0; > } >=20 > Compile option: gcc -S -O2 test.c >=20 >=20 > On aarch64, GCC trunk emits 4 instrunctions: > asr w0, w0, 8 > tst w0, 6 > cset w0, ne > ret >=20 > which can be further simplified into: > tst x0, 1536 > cset w0, ne > ret >=20 > We see the same issue on other targets such as i386 and x86-64. >=20 > Attached please find proposed patch for this issue. The previously posted test case is not correct. Test case should be: int fifth (int c) { int a =3D (c >> 8) & 7; if (a >=3D 2) { return 1; } else { return 0; } }=