[NFC][AggressiveInstCombine] Simplify code for shift truncation

This commit is contained in:
Anton Afanasyev 2021-08-19 19:33:54 +03:00
parent 2eefe4bd17
commit 3890ce708d
1 changed files with 3 additions and 4 deletions

View File

@ -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);