[LLVMdev] a constant folding case causing different results w/ot optimization
Bixia.Zheng at amd.com
Mon Dec 7 15:51:54 PST 2009
The optimizer folds "(unsigned int) -1.0f" to 0. As a result, the
following routine foo returns 0 with optimization, and returns -1
(0xffffffff) without optimization.
unsigned int foo()
float myfloat = -1.0f;
unsigned int myint = (unsigned int) myfloat;
INSTCOMBINE ITERATION #0 on
IC: ConstFold to: i32 0 from: %conv = fptoui float -1.000000e+000 to
i32 ; <i32> [#uses=1]
While the result of "(unsigned int) -1.0f" is probably implementation
defined, both gcc and Microsoft cl produce -1.
Will you consider this an optimizer bug and fix it?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev