Hello,
I came across the following example and their .final_cleanup files. To me, both
functions should produce the same code. But tst1 function actually requires two
extra sign_extend instructions compared with tst2. Is this a C semantics thing,
or GCC mis-compile (over-conservatively) in the first case.
Cheers,
Bingfeng Mei
Broadcom UK
#define A 255
int tst1(short a, short b){
if(a > (b - A))
return 0;
else
return 1;
}
int tst2(short a, short b){
short c = b - A;
if(a > c)
return 0;
else
return 1;
}
.final_cleanup
;; Function tst1 (tst1)
tst1 (short int a, short int b)
{
<bb 2>:
return (int) b + -254 > (int) a;
}
;; Function tst2 (tst2)
tst2 (short int a, short int b)
{
<bb 2>:
return (short int) ((short unsigned int) b + 65281) >= a;
}