public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/110457] New: Unnecessary movsx   eax, dil
@ 2023-06-28 15:05 antoshkka at gmail dot com
  2023-06-28 15:07 ` [Bug target/110457] " antoshkka at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: antoshkka at gmail dot com @ 2023-06-28 15:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110457
           Summary: Unnecessary movsx   eax, dil
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antoshkka at gmail dot com
  Target Milestone: ---

For the following code

int sample1(char c) {
  return (c << 4) + (c << 8) + (c << 16) + c;
}


GCC-14 with -O2 generates the assembly:

sample1(char):
 movsx  eax,dil
 imul   eax,eax,0x10111
 ret


However, it could be shortened to just:

sample1(char):
 imul   eax,edi,0x10111


Godbolt playground: https://godbolt.org/z/7GGdedEY8

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

* [Bug target/110457] Unnecessary movsx   eax, dil
  2023-06-28 15:05 [Bug target/110457] New: Unnecessary movsx eax, dil antoshkka at gmail dot com
@ 2023-06-28 15:07 ` antoshkka at gmail dot com
  2023-06-28 15:58 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: antoshkka at gmail dot com @ 2023-06-28 15:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Antony Polukhin <antoshkka at gmail dot com> ---
> However, it could be shortened to just:

sample1(char):
 imul   eax,edi,0x10111
 ret    ; missed in previous message

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

* [Bug target/110457] Unnecessary movsx   eax, dil
  2023-06-28 15:05 [Bug target/110457] New: Unnecessary movsx eax, dil antoshkka at gmail dot com
  2023-06-28 15:07 ` [Bug target/110457] " antoshkka at gmail dot com
@ 2023-06-28 15:58 ` pinskia at gcc dot gnu.org
  2023-06-28 15:59 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-28 15:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ABI

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Why do you think that?
Iirc the x86_64 abi says the upper bits are undefined.

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

* [Bug target/110457] Unnecessary movsx   eax, dil
  2023-06-28 15:05 [Bug target/110457] New: Unnecessary movsx eax, dil antoshkka at gmail dot com
  2023-06-28 15:07 ` [Bug target/110457] " antoshkka at gmail dot com
  2023-06-28 15:58 ` pinskia at gcc dot gnu.org
@ 2023-06-28 15:59 ` pinskia at gcc dot gnu.org
  2023-06-28 16:29 ` antoshkka at gmail dot com
  2023-06-29 12:10 ` xry111 at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-28 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |X86_64

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note iirc there is still a disagreement in what the abi says. Llvm folks says
it says one thing while gcc folks have said it says it undefined.

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

* [Bug target/110457] Unnecessary movsx   eax, dil
  2023-06-28 15:05 [Bug target/110457] New: Unnecessary movsx eax, dil antoshkka at gmail dot com
                   ` (2 preceding siblings ...)
  2023-06-28 15:59 ` pinskia at gcc dot gnu.org
@ 2023-06-28 16:29 ` antoshkka at gmail dot com
  2023-06-29 12:10 ` xry111 at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: antoshkka at gmail dot com @ 2023-06-28 16:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Antony Polukhin <antoshkka at gmail dot com> ---
Oh, if there's an disagreement I'm fine with closing this issue as
invalid/later/won't_fix

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

* [Bug target/110457] Unnecessary movsx   eax, dil
  2023-06-28 15:05 [Bug target/110457] New: Unnecessary movsx eax, dil antoshkka at gmail dot com
                   ` (3 preceding siblings ...)
  2023-06-28 16:29 ` antoshkka at gmail dot com
@ 2023-06-29 12:10 ` xry111 at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-06-29 12:10 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |xry111 at gcc dot gnu.org
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2023-06-29

--- Comment #5 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
I guess we need an ABI expert to clarify things.

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

end of thread, other threads:[~2023-06-29 12:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-28 15:05 [Bug target/110457] New: Unnecessary movsx eax, dil antoshkka at gmail dot com
2023-06-28 15:07 ` [Bug target/110457] " antoshkka at gmail dot com
2023-06-28 15:58 ` pinskia at gcc dot gnu.org
2023-06-28 15:59 ` pinskia at gcc dot gnu.org
2023-06-28 16:29 ` antoshkka at gmail dot com
2023-06-29 12:10 ` xry111 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).