public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106743] New: Illegal assembly code with -march=skylake
@ 2022-08-25 19:27 stayprivate at gmail dot com
  2022-08-25 19:32 ` [Bug target/106743] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: stayprivate at gmail dot com @ 2022-08-25 19:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106743
           Summary: Illegal assembly code with -march=skylake
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stayprivate at gmail dot com
  Target Milestone: ---

#include <stdint.h>
#include <iostream>

#define swapw(__val)                                                           
                                                           \
        ({                                                                     
                                                                 \
                uint16_t __tmp = __val;                                        
                                                                       \
                __asm__("xchgb %b0, %h0" : "=q"(__tmp) : "0"(__tmp));          
                                                                      \
                __tmp;                                                         
                                                                       \
        })


int main()
{
    int value = rand();
    int a = swapw(value);
    std::cout << std::hex << "First value is " << value << " " << a << '\n';
}

Compile with gcc (gcc 12 on Ubuntu ), and also with trunk. As shown on
https://godbolt.org/z/oGn9WK6GE the assembler will generate the following
error:
: register type mismatch for `xchg'

This is only when using -march=skylake or above and using -O1 or above.

The code works in gcc-9/10/11.

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

end of thread, other threads:[~2022-08-26 12:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-25 19:27 [Bug c++/106743] New: Illegal assembly code with -march=skylake stayprivate at gmail dot com
2022-08-25 19:32 ` [Bug target/106743] " pinskia at gcc dot gnu.org
2022-08-25 19:35 ` pinskia at gcc dot gnu.org
2022-08-26 12:44 ` marxin 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).