Skip to content

Commit 796efa8

Browse files
authored
[Float2Int] Fix pessimization in the MinBW calculation. (#86051)
The MinBW was being calculated using the significant bits of the upper and lower bounds. The upper bound is 1 past the last value in the range so I don't think it should be included. Instead use ConstantRange::getMinSignedBits. I'm still not sure if the +1 is needed after the getMinSignedBits call.
1 parent b3ee127 commit 796efa8

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

llvm/lib/Transforms/Scalar/Float2Int.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,7 @@ bool Float2IntPass::validateAndTransform() {
359359

360360
// The number of bits required is the maximum of the upper and
361361
// lower limits, plus one so it can be signed.
362-
unsigned MinBW = std::max(R.getLower().getSignificantBits(),
363-
R.getUpper().getSignificantBits()) +
364-
1;
362+
unsigned MinBW = R.getMinSignedBits() + 1;
365363
LLVM_DEBUG(dbgs() << "F2I: MinBitwidth=" << MinBW << ", R: " << R << "\n");
366364

367365
// If we've run off the realms of the exactly representable integers,

0 commit comments

Comments
 (0)