In C++, the behavior of casting a double value that is beyond the range
of a single precision floating-point to a float value is undefined. This
change replaces such a cast with APFloat::convert to convert the value,
which is consistent with how we convert a double value to a half value.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
test/Transforms/ConstProp/calls.ll | ||
---|---|---|
199 ↗ | (On Diff #191328) | Bad test. It already is optimized. |
The problem is only reported by ubsan (undefined behavior sanitizer). My test case produces a value of 1.27e+80, which is a value between max(float) and max(double). Without ubsan, llvm opt (compiled with clang for x86) produces the correct result silently. However, since (float)the-double-value has undefined behavior by c++ language, there is no guarantee that the llvm opt produced by any compiler for any platform produces the same result. Do you have suggestion on what is a better test case?
That test doesn't test any of what you have just said.
It only tests that there is no call in the output.
At the very least you probably want to actually test the output, not lack of unwanted output.
test/Transforms/ConstProp/calls.ll | ||
---|---|---|
196 ↗ | (On Diff #191419) | Please add a comment as to what this testing |
test/Transforms/ConstProp/calls.ll | ||
---|---|---|
196 ↗ | (On Diff #191419) | Fwiw I think the f32_overflow suffix makes it clear what it is testing and is consistent with the rest of the file. |