[PATCH] Return undef on conversions that overflow (PR21330).

Sanjay Patel spatel at rotateright.com
Fri Oct 3 09:35:30 PDT 2014


Hi asl, hfinkel, sylvestre.ledru,

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.

http://reviews.llvm.org/D5603

Files:
  lib/IR/ConstantFold.cpp
  test/Transforms/InstCombine/cast.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5603.14384.patch
Type: text/x-patch
Size: 2881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141003/648ebc8d/attachment.bin>


More information about the llvm-commits mailing list