public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110304] New: __builtin_adcs missing and you miss the point of builtin_adcb
@ 2023-06-19  6:01 unlvsur at live dot com
  2023-06-19  6:06 ` [Bug c++/110304] __builtin_adcs missing and jakub " unlvsur at live dot com
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: unlvsur at live dot com @ 2023-06-19  6:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110304
           Summary: __builtin_adcs missing and you miss the point of
                    builtin_adcb
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: unlvsur at live dot com
  Target Milestone: ---

https://github.com/gcc-mirror/gcc/commit/2b4e0415ad664cdb3ce87d1f7eee5ca26911a05b#

This does not include __builtin_adcb, __builtin_adcs and __builtin_subcb,
__builtin_subcs

"
While the design of these builtins in clang is questionable,
rather than being say
unsigned __builtin_addc (unsigned, unsigned, bool, bool *)
"

You miss the point of the point when it falls back to architectures like mips,
wasm, riscv or loongarch where they do not provide flags at all:

template<::std::unsigned_integral T>
inline constexpr T add_carry(T a,T b,T carryin,T& carryout) noexcept
{
    [[assume(carryin==0||carryin==1)]];
    a+=b;
    carryout=a<b;
    a+=carryin;
    carryout+=a<carryin;
    return a;
}


template<::std::unsigned_integral T>
inline constexpr T sub_carry(T a,T b,T carryin,T& carryout) noexcept
{
    [[assume(carryin==0||carryin==1)]];
    a-=b;
    carryout=b<a;
    a-=carryin;
    carryout+=carryin<a;
    return a;
}

Mine is much faster than your __builtin_uadd_overflow on these architectures.

 #define __builtin_addc(a,b,carry_in,carry_out) \
  ({ unsigned _s; \
     unsigned _c1 = __builtin_uadd_overflow (a, b, &_s); \
     unsigned _c2 = __builtin_uadd_overflow (_s, carry_in, &_s); \
     *(carry_out) = (_c1 | _c2); \
     _s; })

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

end of thread, other threads:[~2023-06-20 21:03 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-19  6:01 [Bug c++/110304] New: __builtin_adcs missing and you miss the point of builtin_adcb unlvsur at live dot com
2023-06-19  6:06 ` [Bug c++/110304] __builtin_adcs missing and jakub " unlvsur at live dot com
2023-06-19  6:12 ` unlvsur at live dot com
2023-06-19  6:16 ` unlvsur at live dot com
2023-06-19  6:19 ` jakub at gcc dot gnu.org
2023-06-19  6:22 ` jakub at gcc dot gnu.org
2023-06-19  6:27 ` unlvsur at live dot com
2023-06-19  6:32 ` unlvsur at live dot com
2023-06-19  6:34 ` jakub at gcc dot gnu.org
2023-06-19  6:37 ` unlvsur at live dot com
2023-06-19  6:54 ` unlvsur at live dot com
2023-06-20  3:08 ` unlvsur at live dot com
2023-06-20  6:45 ` jakub at gcc dot gnu.org
2023-06-20 19:17 ` unlvsur at live dot com
2023-06-20 19:40 ` unlvsur at live dot com
2023-06-20 19:41 ` jakub at gcc dot gnu.org
2023-06-20 19:48 ` unlvsur at live dot com
2023-06-20 19:50 ` jakub at gcc dot gnu.org
2023-06-20 20:57 ` unlvsur at live dot com
2023-06-20 21:03 ` unlvsur at live dot com

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