[llvm] 293d813 - [InstCombine] Don't explicitly invoke const folding in shift combine
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 09:35:52 PST 2020
Author: Nikita Popov
Date: 2020-03-04T18:33:00+01:00
New Revision: 293d813020d7f569b107eaea1ca2f6ffc24a047b
URL: https://github.com/llvm/llvm-project/commit/293d813020d7f569b107eaea1ca2f6ffc24a047b
DIFF: https://github.com/llvm/llvm-project/commit/293d813020d7f569b107eaea1ca2f6ffc24a047b.diff
LOG: [InstCombine] Don't explicitly invoke const folding in shift combine
InstCombine uses an IRBuilder that automatically performs
target-dependent constant folding, so explicitly invoking it here
is not necessary.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index 2fed10741ad7..49b178359729 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -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);
More information about the llvm-commits
mailing list