Hi,
I have a case which will generate abs instructions.
int main(int argc)
{
if (argc < 0)
argc = -(unsigned int)argc;
return argc;
}
To my understanding, given that argc=0x80000000 in 32bit int plaform,
the result of (unsigned int)argc is well defined and should be 0x80000000u.
(C99 6.3.1.3 point 2)
And then the result of -0x80000000u should be 0x80000000 because
unsigned operation can never overflow and the value can be
represented by signed integer.
(C99 6.2.5 point 9)
when the case is compiled above -O1,
it would generate abs instruction directly if the target provides
abssi2 naming pattern.
However, if the target's abs have saturation behavior
(i.e abs (0x80000000) = 0x7fffffff)
then the result will wrong.
My question is
Does the abssi2 semantically assume target abs shouldn't do saturation ?
If the target abs have saturation behavior
How should the target generate abs instruction to avoid the wrong result ?
I noticed that there is ss_abs rtx code.
But it seems there is no ss_abssi2 naming pattern.
Any suggestion?
Thanks in advance.
Shiva