public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/99548] New: Help me! Lost the fight against the compiler.
@ 2021-03-11 11:00 unlvsur at live dot com
  2021-03-11 20:10 ` [Bug target/99548] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: unlvsur at live dot com @ 2021-03-11 11:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99548
           Summary: Help me! Lost the fight against the compiler.
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: unlvsur at live dot com
  Target Milestone: ---

https://godbolt.org/z/Kd8q57

The compiler just could not generate as good as assembly as I manually wrote.
Unfortunately, due to the calling convention issues, the inline asm version
would never be portable and hurt other compiler optimizations.


Some patterns like neither GCC nor clang could correctly deal with it.
    std::uint64_t v=0;//set 0 to make compiler happy or it is UB.
    sub_borrow(carry,v,v,v);


        movl    $0, %eax
        movq    %rax, %rdx
        sbbq    %rax, %rdx

What the code actually want is to
sbb %rdx,%rdx
Which is to set the register to the UINT64_MAX when carry (borrow) flag is 1.

        movq    (%rdx), %rcx
        movq    8(%rsi), %r9
        addq    (%rsi), %rcx
        movq    16(%rsi), %r8
        movq    24(%rdx), %rax
        adcq    8(%rdx), %r9
        movq    24(%rsi), %rsi
        adcq    16(%rdx), %r8
        adcq    %rax, %rsi
        movl    $0, %eax

Do we have any possibility to fix those optimization issues in the compiler?

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

end of thread, other threads:[~2021-12-23 21:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 11:00 [Bug rtl-optimization/99548] New: Help me! Lost the fight against the compiler unlvsur at live dot com
2021-03-11 20:10 ` [Bug target/99548] " pinskia at gcc dot gnu.org
2021-03-11 23:35 ` unlvsur at live dot com
2021-12-23 21:45 ` pinskia 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).