[PATCH] D19178: Broaden FoldItoFPtoI to try and establish whether the integer value fits into the float type

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 31 15:03:10 PDT 2016


eli.friedman added inline comments.

================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:1507
@@ +1506,3 @@
+    // then the conversion is undefined behavior.
+
+    Safe = BitRange <= SignificandWidth;
----------------
aarzee wrote:
> eli.friedman wrote:
> > Are you sure subtracting one actually makes the most significant bit zero-indexed? Normally, finding the distance between two array indexes is just simple subtraction; the extra "+1" looks weird.  It's also kind of suspicious that your "zero-based" indexing can return a negative number (as an extreme case, if a 16-bit integer is all ones, your code says the most significant possibly set bit has index -1).
> I'm going to take a look at the actual behavior, I think the least significant possibly set bit might be one-indexed; in any case something is behaving differently than I intended.
> 
> WRT the all-ones case, if a number has no unknown bits then it is by nature a constant, and would be handled by ConstProp, right?
Yes, in the all-ones case it would get turned into a constant; not sure off the top of my head if that's guaranteed to happen before this code runs, though.


https://reviews.llvm.org/D19178





More information about the llvm-commits mailing list