public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/103784] New: suboptimal code for returning bool value on target ppc
@ 2021-12-21  1:42 guihaoc at gcc dot gnu.org
  2021-12-21  1:46 ` [Bug target/103784] " pinskia at gcc dot gnu.org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: guihaoc at gcc dot gnu.org @ 2021-12-21  1:42 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-08-31  8:04 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-21  1:42 [Bug target/103784] New: suboptimal code for returning bool value on target ppc guihaoc at gcc dot gnu.org
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

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).