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

            Bug ID: 115973
           Summary: PPCLE: Inefficient code for __builtin_uaddll_overflow
                    and __builtin_addcll
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jens.seifert at de dot ibm.com
  Target Milestone: ---

unsigned long long add(unsigned long long a, unsigned long long b, unsigned
long long *ovf)
{
   return __builtin_addcll(a,b,0,ovf);
}
creates
        mr 9,3
        add 3,3,4
        subfc 9,9,3
        subfe 9,9,9
        neg 9,9
        std 9,0(5)
        blr

Expected to addc + addze

unsigned long long add4(unsigned long long a, unsigned long long b, unsigned
long long *ovf)
{
   unsigned long long t, res;
   __asm__("li %0, 0; addc %1,%2,%3; addze
%0,%0":"=&r"(res),"=r"(t):"r"(a),"r"(b):"xer");
   *ovf = res;
   return t;
}

Expected assembly
        li 9, 0
        addc 3,3,4
        addze 9,9
        std 9,0(5)
        blr
  • [Bug target/115973] New: PPCLE... jens.seifert at de dot ibm.com via Gcc-bugs

Reply via email to