-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Description
When using clang (-O3) to convert a floating point constant such as -1234.56 into an unsigned integer and then printing out the converted result with printf, it produces a random value; whereas when using gcc(-O3) it outputs 0 instead.
#include <stdio.h>
int main(int argc, char * argv[]) {
float x = -1234.56;
unsigned int res = (unsigned int)x;
printf("res: %u\n", res);
return 0;
}
I have observed that when optimizing with -O3 flag, constant folding occurs during the EarlyCSE pass. However, during conversion within IEEEFloat module fails and results in oplnvalidOp which causes the conversion result to become poison. As a consequence of this poisoned parameter being passed through esi register according to x64 ABI standard rules , there exists an IMPLICIT_DEF statement assigning a value to rsi register which gets removed later on during processimpdefs pass leading ultimately leads producing random values being printed by printf function call . Do you know if there are any solutions available for this issue?