public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "guihaoc at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-103784-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103784 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 <stdbool.h> 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 integer, 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
next reply other threads:[~2021-12-21 1:42 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-21 1:42 guihaoc at gcc dot gnu.org [this message] 2021-12-21 1:46 ` [Bug target/103784] " pinskia at gcc dot gnu.org 2021-12-21 2:35 ` guihaoc at gcc dot gnu.org 2021-12-21 2:43 ` pinskia at gcc dot gnu.org 2021-12-21 3:02 ` guihaoc at gcc dot gnu.org 2023-01-04 14:07 ` segher at gcc dot gnu.org 2023-01-04 14:08 ` segher at gcc dot gnu.org 2023-01-04 14:13 ` segher at gcc dot gnu.org 2023-01-05 16:34 ` jskumari at gcc dot gnu.org 2023-03-01 4:04 ` jskumari at gcc dot gnu.org 2023-03-05 11:48 ` jskumari at gcc dot gnu.org 2023-03-05 15:41 ` dje at gcc dot gnu.org 2023-03-05 19:27 ` segher at gcc dot gnu.org 2023-03-06 8:14 ` jskumari at gcc dot gnu.org 2023-03-16 9:52 ` rguenth at gcc dot gnu.org 2023-04-11 17:07 ` aagarwa at gcc dot gnu.org 2023-07-20 11:15 ` jskumari at gcc dot gnu.org 2023-08-31 8:03 ` aagarwa at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-103784-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).