public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/102239] New: powerpc suboptimal boolean test of contiguous bits
@ 2021-09-08 11:55 npiggin at gmail dot com
  2021-09-09 19:40 ` [Bug target/102239] " segher at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: npiggin at gmail dot com @ 2021-09-08 11:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102239

            Bug ID: 102239
           Summary: powerpc suboptimal boolean test of contiguous bits
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: npiggin at gmail dot com
  Target Milestone: ---
            Target: powerpc64le-linux-gnu

gcc version 11.2.1 20210815 (Debian 11.2.0-2) 

Build flags -O2

--- test.c ---
void foo(long arg)
{
        if (arg & ((1UL << 33) | (1UL << 34)))
                asm volatile("# if");
        else
                asm volatile("# else");
}
---

generates:

foo:
        rldicr 3,3,29,1
        srdi. 3,3,29
        beq 0,.L6
        # if
        blr
.L6:
        # else
        blr

This test of multiple contiguous bits could be tested with a single instruction
with rldicr. or rldicl.

Those instructions do tend to be more expensive than the Rc=0 form (C2 cracked
on POWER9, slower pipe class on POWER10), but I think they should be better
than the current 2-instruction sequence.

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

end of thread, other threads:[~2022-01-12  0:27 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-08 11:55 [Bug c/102239] New: powerpc suboptimal boolean test of contiguous bits npiggin at gmail dot com
2021-09-09 19:40 ` [Bug target/102239] " segher at gcc dot gnu.org
2021-11-24  7:17 ` luoxhu at gcc dot gnu.org
2021-11-24 23:22 ` segher at gcc dot gnu.org
2021-11-26  8:50 ` luoxhu at gcc dot gnu.org
2021-11-26 15:53 ` segher at gcc dot gnu.org
2021-11-29  3:31 ` luoxhu at gcc dot gnu.org
2021-11-29  6:36 ` luoxhu at gcc dot gnu.org
2021-11-29 10:05 ` segher at gcc dot gnu.org
2021-11-30  5:28 ` luoxhu at gcc dot gnu.org
2021-11-30 22:59 ` segher at gcc dot gnu.org
2021-12-01  7:46 ` luoxhu at gcc dot gnu.org
2022-01-11  9:23 ` cvs-commit at gcc dot gnu.org
2022-01-12  0:27 ` luoxhu 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).