From 3eec73e20b8fce19bf2754b270968e876fb31e9d Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 10 Apr 2017 16:40:00 +0000 Subject: [InstCombine] Support folding of add instructions with vector constants into select operations We currently only fold scalar add of constants into selects. This improves this to support vectors too. Differential Revision: https://reviews.llvm.org/D31683 llvm-svn: 299847 --- llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp index c946c096821..65f72d0fb55 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -1128,8 +1128,8 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { } } - if (isa(RHS) && isa(LHS)) - if (Instruction *NV = FoldOpIntoPhi(I)) + if (isa(RHS)) + if (Instruction *NV = foldOpWithConstantIntoOperand(I)) return NV; if (I.getType()->getScalarType()->isIntegerTy(1)) @@ -1200,11 +1200,6 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { return BinaryOperator::CreateAnd(NewAdd, C2); } } - - // Try to fold constant add into select arguments. - if (SelectInst *SI = dyn_cast(LHS)) - if (Instruction *R = FoldOpIntoSelect(I, SI)) - return R; } // add (select X 0 (sub n A)) A --> select X A n -- cgit v1.2.3