[PATCH] stdlib: Implement C2Y uabs, ulabs, ullabs and uimaxabs

Paul Eggert eggert@cs.ucla.edu
Fri Mar 7 20:48:04 GMT 2025


On 2025-03-07 12:30, Lenard wrote:
> The rationale for using ckd_mul in N3349 was portability.

I see, but at least use ckd_sub as that's more natural than ckd_mul.

Also, it's nicer to have the source code match what the machine code 
does, and as there is no conditional branch at the machine level there 
is no need for an "if" statement at the source level. Perhaps something 
like the following, which generates the same instructions:

   unsigned int
   uabs (int i)
   {
     unsigned int u;
     __builtin_sub_overflow (0, i, &u);
     return i < 0 ? u : i;
   }



More information about the Libc-alpha mailing list