public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/108371] New: gcc for x86_64 may sign/zero extent arguments unnecessarily
@ 2023-01-11 14:04 dhowells at redhat dot com
  2023-01-11 14:28 ` [Bug target/108371] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: dhowells at redhat dot com @ 2023-01-11 14:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108371
           Summary: gcc for x86_64 may sign/zero extent arguments
                    unnecessarily
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dhowells at redhat dot com
  Target Milestone: ---

When compiling for x86_64, bool, char and short arguments that are passed
directly to an argument of exactly the same type on another function with no
modification, e.g.:

   void __bio_release_pages(char mark_dirty);
   void bio_release_pages(char mark_dirty)
   {
        __bio_release_pages(mark_dirty);
   }

get sign/zero-extended unnecessarily.  In the case of the above code, it
compiles to:

   0:   40 0f be ff             movsbl %dil,%edi
   4:   e9 00 00 00 00          jmp    9 <bio_release_pages+0x9>

with "gcc -Os -c test.c".  Can the extension be optimised away?  Granted, the
upper bits bits of RDI could contain rubbish on entry to bio_release_pages(),
so sanitisation is not unreasonable - but on the other hand,
__bio_release_pages() would surely have to assume the same and do the same
sanitisation?

The toolchain used is the Fedora 37 system compiler:

gcc-12.2.1-4.fc37.x86_64
binutils-2.38-25.fc37.x86_64

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

* [Bug target/108371] gcc for x86_64 may sign/zero extent arguments unnecessarily
  2023-01-11 14:04 [Bug target/108371] New: gcc for x86_64 may sign/zero extent arguments unnecessarily dhowells at redhat dot com
@ 2023-01-11 14:28 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-01-11 14:28 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-*-*
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-01-11
           Keywords|                            |missed-optimization
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  This is the C frontend doing

;; Function bio_release_pages (null)
;; enabled by -tree-original


{
  __bio_release_pages ((int) mark_dirty);
}

aka targetm.calls.promote_prototypes

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

end of thread, other threads:[~2023-01-11 14:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11 14:04 [Bug target/108371] New: gcc for x86_64 may sign/zero extent arguments unnecessarily dhowells at redhat dot com
2023-01-11 14:28 ` [Bug target/108371] " rguenth 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).