From 293d813020d7f569b107eaea1ca2f6ffc24a047b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 4 Mar 2020 18:33:00 +0100 Subject: [PATCH] [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. --- llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp index 2fed107..49b1783 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(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 should already do this. - if (auto *C = dyn_cast(V)) - V = ConstantFoldConstant(C, DL, &IC.getTargetLibraryInfo()); - return V; + return IC.Builder.CreateLShr(C, NumBits); } Instruction *I = cast(V); -- 2.7.4