[PATCH] D53794: [TargetLowering] expandFP_TO_UINT - avoid FPE due to out of range conversion (PR17686)
Ulrich Weigand via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 19 05:11:44 PST 2018
uweigand added a comment.
As I understand the approach, it can never **introduce** a new trap. Now of course, if the original source value is outside the range of the target integer type, some of the instructions introduced by this approach may trap, but in that case, it is expected for the fp_to_uint operation to trap somewhere.
If the original source value is in range however, then none of the instructions introduced here can ever trap:
// Sel = Src < 0x8000000000000000
// Val = select Sel, Src, Src - 0x8000000000000000
// Ofs = select Sel, 0, 0x8000000000000000
// Result = fp_to_sint(Val) ^ Ofs
The first is a compare that never traps. The select operations themselves also never trap. The first select in addition contains a subtraction, but if Src is in range for the fp_to_uint operation, that subtract cannot trap either. Finally, if Src is in range for fp_to_uint, then by construction the value Val will be in range for fp_to_sint, and therefore that operation cannot trap either.
Repository:
rL LLVM
https://reviews.llvm.org/D53794
More information about the llvm-commits
mailing list