Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp =================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -1128,8 +1128,8 @@ } } - 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 @@ 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 Index: llvm/trunk/test/Transforms/InstCombine/add.ll =================================================================== --- llvm/trunk/test/Transforms/InstCombine/add.ll +++ llvm/trunk/test/Transforms/InstCombine/add.ll @@ -272,8 +272,7 @@ define <2 x i32> @test19vec(i1 %C) { ; CHECK-LABEL: @test19vec( -; CHECK-NEXT: [[A:%.*]] = select i1 [[C:%.*]], <2 x i32> , <2 x i32> -; CHECK-NEXT: [[V:%.*]] = add nuw nsw <2 x i32> [[A]], +; CHECK-NEXT: [[V:%.*]] = select i1 [[C:%.*]], <2 x i32> , <2 x i32> ; CHECK-NEXT: ret <2 x i32> [[V]] ; %A = select i1 %C, <2 x i32> , <2 x i32> @@ -604,8 +603,7 @@ define <2 x i32> @test42vec(i1 %C) { ; CHECK-LABEL: @test42vec( -; CHECK-NEXT: [[A:%.*]] = select i1 [[C:%.*]], <2 x i32> , <2 x i32> -; CHECK-NEXT: [[V:%.*]] = add nuw nsw <2 x i32> [[A]], +; CHECK-NEXT: [[V:%.*]] = select i1 [[C:%.*]], <2 x i32> , <2 x i32> ; CHECK-NEXT: ret <2 x i32> [[V]] ; %A = select i1 %C, <2 x i32> , <2 x i32> @@ -615,8 +613,7 @@ define <2 x i32> @test42vec2(i1 %C) { ; CHECK-LABEL: @test42vec2( -; CHECK-NEXT: [[A:%.*]] = select i1 [[C:%.*]], <2 x i32> , <2 x i32> -; CHECK-NEXT: [[V:%.*]] = add nuw nsw <2 x i32> [[A]], +; CHECK-NEXT: [[V:%.*]] = select i1 [[C:%.*]], <2 x i32> , <2 x i32> ; CHECK-NEXT: ret <2 x i32> [[V]] ; %A = select i1 %C, <2 x i32> , <2 x i32>