From: Chris Lattner Date: Tue, 8 Oct 2002 16:16:40 +0000 (+0000) Subject: Fold ashr -1, X into -1 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=6eaeb5764cc683c356ad1a8c13ad94151de030f2;p=oota-llvm.git Fold ashr -1, X into -1 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4070 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index ec3ea074d92..f0e639742dc 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -503,6 +503,12 @@ Instruction *InstCombiner::visitShiftInst(Instruction &I) { return BinaryOperator::create(Instruction::Add, Op0, Op0, I.getName()); } + + // shr int -1, X = -1 (for any arithmetic shift rights of ~0) + if (ConstantSInt *CSI = dyn_cast(Op0)) + if (I.getOpcode() == Instruction::Shr && CSI->isAllOnesValue()) + return ReplaceInstUsesWith(I, CSI); + return 0; }