https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43892
--- Comment #34 from Joakim Tjernlund <joakim.tjernlund at infinera dot com> ---
(In reply to Christophe Leroy from comment #28)
> Looks like we have a way to do it. Works at least with GCC 5.5, 8.2, 9.2,
> 10.1
>
> unsigned long g(unsigned long a, unsigned long b)
> {
> unsigned long long s = (unsigned long long)a + (unsigned long long)b;
>
> return (s >> 32) + s;
> }
>
> 00000020 <g>:
> 20: 7c 63 20 14 addc r3,r3,r4
> 24: 7c 63 01 94 addze r3,r3
> 28: 4e 80 00 20 blr
>
Does that work when placed in a loop to?
Something close to the example in the first comment:
for(;len; --len)
sum = add32carry(sum, *++buf);
addic 3, 3, 0 /* clear carry */
.L31:
lwzu 0,4(9)
adde 3, 3, 0 /* add with carry */
bdnz .L31
addze 3, 3 /* add in final carry */