public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/114004] New: GCC emits a superfluous instruction for simple test case on ppc
@ 2024-02-20  0:53 bergner at gcc dot gnu.org
  2024-02-20  0:59 ` [Bug target/114004] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: bergner at gcc dot gnu.org @ 2024-02-20  0:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114004
           Summary: GCC emits a superfluous instruction for simple test
                    case on ppc
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bergner at gcc dot gnu.org
  Target Milestone: ---

We emit a superfluous rldicl insn for the following test case.  The rlwinm is
all that is needed/required.  This is not a regression.

bergner@ltcden2-lp1:PR112103$ cat bug.c 
unsigned int
rot (unsigned int x)
{
 return x & 0xbfffffff;
}
bergner@ltcden2-lp1:PR112103$ /opt/gcc-nightly/trunk/bin/gcc -S -O2 bug.c 
bergner@ltcden2-lp1:PR112103$ cat bug.s 
        .file   "bug.c"
        .machine power10
        .abiversion 2
        .section        ".text"
        .align 2
        .p2align 4,,15
        .globl rot
        .type   rot, @function
rot:
.LFB0:
        .cfi_startproc
        .localentry     rot,1
        rlwinm 3,3,0,2,0
        rldicl 3,3,0,32
        blr
        .long 0
        .byte 0,0,0,0,0,0,0,0
        .cfi_endproc
.LFE0:
        .size   rot,.-rot
        .ident  "GCC: (GNU) 14.0.1 20240219 (experimental) [remotes/origin/HEAD
r14-9074-gd70facd54a]"
        .section        .note.GNU-stack,"",@progbits

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

* [Bug target/114004] GCC emits a superfluous instruction for simple test case on ppc
  2024-02-20  0:53 [Bug target/114004] New: GCC emits a superfluous instruction for simple test case on ppc bergner at gcc dot gnu.org
@ 2024-02-20  0:59 ` pinskia at gcc dot gnu.org
  2024-02-27 14:26 ` jskumari at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-20  0:59 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-02-20
             Status|UNCONFIRMED                 |NEW
                 CC|                            |pinskia at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. I thought I saw something similar to this years ago.

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

* [Bug target/114004] GCC emits a superfluous instruction for simple test case on ppc
  2024-02-20  0:53 [Bug target/114004] New: GCC emits a superfluous instruction for simple test case on ppc bergner at gcc dot gnu.org
  2024-02-20  0:59 ` [Bug target/114004] " pinskia at gcc dot gnu.org
@ 2024-02-27 14:26 ` jskumari at gcc dot gnu.org
  2024-04-06 21:50 ` segher at gcc dot gnu.org
  2024-06-13 17:06 ` segher at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jskumari at gcc dot gnu.org @ 2024-02-27 14:26 UTC (permalink / raw)
  To: gcc-bugs

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

Surya Kumari Jangala <jskumari at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

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

* [Bug target/114004] GCC emits a superfluous instruction for simple test case on ppc
  2024-02-20  0:53 [Bug target/114004] New: GCC emits a superfluous instruction for simple test case on ppc bergner at gcc dot gnu.org
  2024-02-20  0:59 ` [Bug target/114004] " pinskia at gcc dot gnu.org
  2024-02-27 14:26 ` jskumari at gcc dot gnu.org
@ 2024-04-06 21:50 ` segher at gcc dot gnu.org
  2024-06-13 17:06 ` segher at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: segher at gcc dot gnu.org @ 2024-04-06 21:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Segher Boessenkool <segher at gcc dot gnu.org> ---
So, the rlwinm keeps all the top 32 bits intact, but those are all zero to
begin
with.  Somehow we don't see that, or don't take that into account anyway.

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

* [Bug target/114004] GCC emits a superfluous instruction for simple test case on ppc
  2024-02-20  0:53 [Bug target/114004] New: GCC emits a superfluous instruction for simple test case on ppc bergner at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-04-06 21:50 ` segher at gcc dot gnu.org
@ 2024-06-13 17:06 ` segher at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: segher at gcc dot gnu.org @ 2024-06-13 17:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Segher Boessenkool <segher at gcc dot gnu.org> ---
We have very many similar PRs reported over the years, but more for when the
argument is *signed*, actually!  There, we end up with unneeded sign-extension
insns often (which are easier to spot than extra rl* insns).

With most of our ABIs the *caller* is required to sign- or zero-extend the
parameters.  A function always can depend on this (the compiler can count on
this when compiling any function, put a bit more correctly).

Maybe we can put some RTL at the start of every function that makes this clear?
Some RTL that ends up matching a define_insn that doesn't actually emit any
assembler code in the end.  Or maybe there is something that can be done in the
Gimple passes already (I don't see anything better for the RTL passes,
unfortunately).

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

end of thread, other threads:[~2024-06-13 17:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-20  0:53 [Bug target/114004] New: GCC emits a superfluous instruction for simple test case on ppc bergner at gcc dot gnu.org
2024-02-20  0:59 ` [Bug target/114004] " pinskia at gcc dot gnu.org
2024-02-27 14:26 ` jskumari at gcc dot gnu.org
2024-04-06 21:50 ` segher at gcc dot gnu.org
2024-06-13 17:06 ` segher 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).