Skip to content

Commit

Permalink
[NFC][AggressiveInstCombine] Simplify code for shift truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-afanasyev committed Aug 20, 2021
1 parent 2eefe4b commit 3890ce7
Showing 1 changed file with 3 additions and 4 deletions.
Expand Up @@ -286,11 +286,10 @@ Type *TruncInstCombine::getBestTruncatedType() {
if (I->getOpcode() == Instruction::Shl ||
I->getOpcode() == Instruction::LShr) {
KnownBits KnownRHS = computeKnownBits(I->getOperand(1), DL);
const unsigned SrcBitWidth = KnownRHS.getBitWidth();
unsigned MinBitWidth = KnownRHS.getMaxValue()
.uadd_sat(APInt(SrcBitWidth, 1))
.getLimitedValue(SrcBitWidth);
if (MinBitWidth >= OrigBitWidth)
.uadd_sat(APInt(OrigBitWidth, 1))
.getLimitedValue(OrigBitWidth);
if (MinBitWidth == OrigBitWidth)
return nullptr;
if (I->getOpcode() == Instruction::LShr) {
KnownBits KnownLHS = computeKnownBits(I->getOperand(0), DL);
Expand Down

0 comments on commit 3890ce7

Please sign in to comment.