From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DB56A3858C60; Tue, 21 Dec 2021 01:42:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB56A3858C60 From: "guihaoc at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/103784] New: suboptimal code for returning bool value on target ppc Date: Tue, 21 Dec 2021 01:42:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: guihaoc 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 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 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, 21 Dec 2021 01:42:32 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103784 Bug ID: 103784 Summary: suboptimal code for returning bool value on target ppc Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: guihaoc at gcc dot gnu.org Target Milestone: --- //test.c #include bool foo (int a, int b) { if (a > 2) return false; if (b < 10) return true; return true; } //assembly with trunk ld 9,0(3) cmpdi 0,9,0 add 10,9,4 beq 0,.L5 ldarx 8,0,3 cmpd 0,8,9 bne 0,.L4 stdcx. 10,0,3 bne 0,.L4 li 3,1 rldicl 3,3,0,63 blr .p2align 4,,15 .L5: li 3,0 rldicl 3,3,0,63 blr //assembly with at13.0 subfic 3,3,2 srdi 3,3,63 xori 3,3,0x1 blr The second branch and two zero extend are unnecessary. If it returns a inte= ger, the code seems good. //test1.c int foo (int a, int b) { if (a > 2) return 0; if (b < 10) return 1; return 1; } //assembly with trunk li 9,1 cmpwi 0,3,2 isel 3,0,9,1 blr=