public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111209] New: GCC fails to understand adc pattern
@ 2023-08-28  6:47 unlvsur at live dot com
  2023-08-28 18:56 ` [Bug target/111209] GCC fails to understand adc pattern what its document describes jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: unlvsur at live dot com @ 2023-08-28  6:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111209
           Summary: GCC fails to understand adc pattern
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: unlvsur at live dot com
  Target Milestone: ---

Created attachment 55805
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55805&action=edit
bug example

template<typename T>
inline constexpr T addc(T a,T b,bool carryin,bool& carryout) noexcept
{
        T s;
        auto c1 = __builtin_add_overflow(a, b, __builtin_addressof(s));
        auto c2 = __builtin_add_overflow(s, carryin, __builtin_addressof(s));
        carryout = c1 | c2;
        return s;
}

void test_addc(unsigned long long* a,unsigned long long* b,unsigned long long*
r)
{
    bool carry{};
    r[0]=addc(a[0],b[0],carry,carry);
    r[1]=addc(a[1],b[1],carry,carry);
}

I copied the example from gcc documentation

https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html

But gcc seems to fail to understand the pattern correctly even with what the
document describes.
gcc:
https://godbolt.org/z/Whaaahn41

clang:
https://godbolt.org/z/Ma6rvaYd6

Looks like a bug here.

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

end of thread, other threads:[~2023-08-29  8:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-28  6:47 [Bug tree-optimization/111209] New: GCC fails to understand adc pattern unlvsur at live dot com
2023-08-28 18:56 ` [Bug target/111209] GCC fails to understand adc pattern what its document describes jakub at gcc dot gnu.org
2023-08-28 18:58 ` [Bug middle-end/111209] " jakub at gcc dot gnu.org
2023-08-28 19:02 ` unlvsur at live dot com
2023-08-28 19:04 ` jakub at gcc dot gnu.org
2023-08-28 19:08 ` unlvsur at live dot com
2023-08-29  8:47 ` cvs-commit 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).