Return undef on FP <-> Int conversions that overflow (PR21330).
authorSanjay Patel <spatel@rotateright.com>
Fri, 10 Oct 2014 23:00:21 +0000 (23:00 +0000)
committerSanjay Patel <spatel@rotateright.com>
Fri, 10 Oct 2014 23:00:21 +0000 (23:00 +0000)
commitad8b666624e17bfc89a684cf060d96c3b6905d92
tree8f776fe2544701055f7ac30509ff975313ab3252
parent96983b89b01e65a96919760557f3b6e90a32408a
Return undef on FP <-> Int conversions that overflow (PR21330).

The LLVM Lang Ref states for signed/unsigned int to float conversions:
"If the value cannot fit in the floating point value, the results are undefined."

And for FP to signed/unsigned int:
"If the value cannot fit in ty2, the results are undefined."

This matches the C definitions.

The existing behavior pins to infinity or a max int value, but that may just
lead to more confusion as seen in:
http://llvm.org/bugs/show_bug.cgi?id=21130

Returning undef will hopefully lead to a less silent failure.

Differential Revision: http://reviews.llvm.org/D5603

llvm-svn: 219542
llvm/lib/IR/ConstantFold.cpp
llvm/test/Transforms/InstCombine/cast.ll