Skip to content

Commit

Permalink
[InstCombine] Don't explicitly invoke const folding in shift combine
Browse files Browse the repository at this point in the history
InstCombine uses an IRBuilder that automatically performs
target-dependent constant folding, so explicitly invoking it here
is not necessary.
  • Loading branch information
nikic committed Mar 4, 2020
1 parent 9b5de84 commit 293d813
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
Expand Up @@ -612,14 +612,9 @@ static Value *getShiftedValue(Value *V, unsigned NumBits, bool isLeftShift,
// We can always evaluate constants shifted.
if (Constant *C = dyn_cast<Constant>(V)) {
if (isLeftShift)
V = IC.Builder.CreateShl(C, NumBits);
return IC.Builder.CreateShl(C, NumBits);
else
V = IC.Builder.CreateLShr(C, NumBits);
// If we got a constantexpr back, try to simplify it with TD info.
// TODO: This is dubious, IRBuilder<TargetFolder> should already do this.
if (auto *C = dyn_cast<Constant>(V))
V = ConstantFoldConstant(C, DL, &IC.getTargetLibraryInfo());
return V;
return IC.Builder.CreateLShr(C, NumBits);
}

Instruction *I = cast<Instruction>(V);
Expand Down

0 comments on commit 293d813

Please sign in to comment.