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

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