diff --git a/clang/test/CodeGen/complex-math.c b/clang/test/CodeGen/complex-math.c --- a/clang/test/CodeGen/complex-math.c +++ b/clang/test/CodeGen/complex-math.c @@ -149,7 +149,7 @@ // AARCH64-FASTMATH: [[CCpDD:%.*]] = fadd fast float [[CC]], [[DD]] // // BC = 0 - // AARCH64-FASTMATH: [[NEGA:%.*]] = fsub fast float -0.000000e+00, %a + // AARCH64-FASTMATH: [[NEGA:%.*]] = fneg fast float %a // AARCH64-FASTMATH: [[AD:%.*]] = fmul fast float [[D]], [[NEGA]] // // AARCH64-FASTMATH: fdiv fast float [[AC]], [[CCpDD]] @@ -327,7 +327,7 @@ // AARCH64-FASTMATH: [[CCpDD:%.*]] = fadd fast double [[CC]], [[DD]] // // BC = 0 - // AARCH64-FASTMATH: [[NEGA:%.*]] = fsub fast double -0.000000e+00, %a + // AARCH64-FASTMATH: [[NEGA:%.*]] = fneg fast double %a // AARCH64-FASTMATH: [[AD:%.*]] = fmul fast double [[D]], [[NEGA]] // // AARCH64-FASTMATH: fdiv fast double [[AC]], [[CCpDD]] @@ -523,7 +523,7 @@ // AARCH64-FASTMATH: [[CCpDD:%.*]] = fadd fast fp128 [[CC]], [[DD]] // // BC = 0 - // AARCH64-FASTMATH: [[NEGA:%.*]] = fsub fast fp128 0xL00000000000000008000000000000000, %a + // AARCH64-FASTMATH: [[NEGA:%.*]] = fneg fast fp128 %a // AARCH64-FASTMATH: [[AD:%.*]] = fmul fast fp128 [[D]], [[NEGA]] // // AARCH64-FASTMATH: fdiv fast fp128 [[AC]], [[CCpDD]] diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -154,18 +154,20 @@ } #include "llvm/IR/Instruction.def" - static UnaryOperator *CreateWithCopiedFlags(UnaryOps Opc, - Value *V, - Instruction *CopyO, - const Twine &Name = "") { - UnaryOperator *UO = Create(Opc, V, Name); + static UnaryOperator * + CreateWithCopiedFlags(UnaryOps Opc, Value *V, Instruction *CopyO, + const Twine &Name = "", + Instruction *InsertBefore = nullptr) { + UnaryOperator *UO = Create(Opc, V, Name, InsertBefore); UO->copyIRFlags(CopyO); return UO; } static UnaryOperator *CreateFNegFMF(Value *Op, Instruction *FMFSource, - const Twine &Name = "") { - return CreateWithCopiedFlags(Instruction::FNeg, Op, FMFSource, Name); + const Twine &Name = "", + Instruction *InsertBefore = nullptr) { + return CreateWithCopiedFlags(Instruction::FNeg, Op, FMFSource, Name, + InsertBefore); } UnaryOps getOpcode() const { @@ -280,11 +282,6 @@ const Twine &Name = "") { return CreateWithCopiedFlags(Instruction::FRem, V1, V2, FMFSource, Name); } - static BinaryOperator *CreateFNegFMF(Value *Op, Instruction *FMFSource, - const Twine &Name = "") { - Value *Zero = ConstantFP::getNegativeZero(Op->getType()); - return CreateWithCopiedFlags(Instruction::FSub, Zero, Op, FMFSource, Name); - } static BinaryOperator *CreateNSW(BinaryOps Opc, Value *V1, Value *V2, const Twine &Name = "") { @@ -390,10 +387,6 @@ Instruction *InsertBefore = nullptr); static BinaryOperator *CreateNUWNeg(Value *Op, const Twine &Name, BasicBlock *InsertAtEnd); - static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name = "", - Instruction *InsertBefore = nullptr); - static BinaryOperator *CreateFNeg(Value *Op, const Twine &Name, - BasicBlock *InsertAtEnd); static BinaryOperator *CreateNot(Value *Op, const Twine &Name = "", Instruction *InsertBefore = nullptr); static BinaryOperator *CreateNot(Value *Op, const Twine &Name, diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -2393,20 +2393,6 @@ return BinaryOperator::CreateNUWSub(zero, Op, Name, InsertAtEnd); } -BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const Twine &Name, - Instruction *InsertBefore) { - Value *zero = ConstantFP::getZeroValueForNegation(Op->getType()); - return new BinaryOperator(Instruction::FSub, zero, Op, - Op->getType(), Name, InsertBefore); -} - -BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const Twine &Name, - BasicBlock *InsertAtEnd) { - Value *zero = ConstantFP::getZeroValueForNegation(Op->getType()); - return new BinaryOperator(Instruction::FSub, zero, Op, - Op->getType(), Name, InsertAtEnd); -} - BinaryOperator *BinaryOperator::CreateNot(Value *Op, const Twine &Name, Instruction *InsertBefore) { Constant *C = Constant::getAllOnesValue(Op->getType()); diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -2136,7 +2136,7 @@ // fsub nsz 0, X ==> fsub nsz -0.0, X Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); if (I.hasNoSignedZeros() && match(Op0, m_PosZeroFP())) - return BinaryOperator::CreateFNegFMF(Op1, &I); + return UnaryOperator::CreateFNegFMF(Op1, &I); if (Instruction *X = foldFNegIntoConstant(I)) return X; @@ -2214,12 +2214,12 @@ if (I.hasAllowReassoc() && I.hasNoSignedZeros()) { // (Y - X) - Y --> -X if (match(Op0, m_FSub(m_Specific(Op1), m_Value(X)))) - return BinaryOperator::CreateFNegFMF(X, &I); + return UnaryOperator::CreateFNegFMF(X, &I); // Y - (X + Y) --> -X // Y - (Y + X) --> -X if (match(Op1, m_c_FAdd(m_Specific(Op0), m_Value(X)))) - return BinaryOperator::CreateFNegFMF(X, &I); + return UnaryOperator::CreateFNegFMF(X, &I); // (X * C) - X --> X * (C - 1.0) if (match(Op0, m_FMul(m_Specific(Op1), m_Constant(C)))) { diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -2189,7 +2189,7 @@ llvm_unreachable("unexpected intrinsic ID"); } Value *NewCall = Builder.CreateBinaryIntrinsic(NewIID, X, Y, II); - Instruction *FNeg = BinaryOperator::CreateFNeg(NewCall); + Instruction *FNeg = UnaryOperator::CreateFNeg(NewCall); FNeg->copyIRFlags(II); return FNeg; } @@ -2354,7 +2354,7 @@ if (match(II->getArgOperand(0), m_OneUse(m_FNeg(m_Value(X))))) { // sin(-x) --> -sin(x) Value *NewSin = Builder.CreateUnaryIntrinsic(Intrinsic::sin, X, II); - Instruction *FNeg = BinaryOperator::CreateFNeg(NewSin); + Instruction *FNeg = UnaryOperator::CreateFNeg(NewSin); FNeg->copyFastMathFlags(II); return FNeg; } diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -1639,7 +1639,7 @@ // FIXME: Once we're sure that unary FNeg optimizations are on par with // binary FNeg, this should always return a unary operator. if (isa(Op)) - return BinaryOperator::CreateFNegFMF(InnerTrunc, Op); + return UnaryOperator::CreateFNegFMF(InnerTrunc, Op); return UnaryOperator::CreateFNegFMF(InnerTrunc, Op); } diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -411,7 +411,7 @@ // X * -1.0 --> -X Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); if (match(Op1, m_SpecificFP(-1.0))) - return BinaryOperator::CreateFNegFMF(Op0, &I); + return UnaryOperator::CreateFNegFMF(Op0, &I); // -X * -Y --> X * Y Value *X, *Y; diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -341,7 +341,7 @@ // TODO: Remove the hack for the binop form when the unary op is optimized // properly with all IR passes. if (TI->getOpcode() != Instruction::FNeg) - return BinaryOperator::CreateFNegFMF(NewSel, cast(TI)); + return UnaryOperator::CreateFNegFMF(NewSel, cast(TI)); return UnaryOperator::CreateFNeg(NewSel); } diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -254,15 +254,15 @@ } } -static BinaryOperator *CreateNeg(Value *S1, const Twine &Name, - Instruction *InsertBefore, Value *FlagsOp) { +static Instruction *CreateNeg(Value *S1, const Twine &Name, + Instruction *InsertBefore, Value *FlagsOp) { if (S1->getType()->isIntOrIntVectorTy()) return BinaryOperator::CreateNeg(S1, Name, InsertBefore); - else { - BinaryOperator *Res = BinaryOperator::CreateFNeg(S1, Name, InsertBefore); - Res->setFastMathFlags(cast(FlagsOp)->getFastMathFlags()); - return Res; - } + + if (auto *FMFSource = dyn_cast(FlagsOp)) + return UnaryOperator::CreateFNegFMF(S1, FMFSource, Name, InsertBefore); + + return UnaryOperator::CreateFNeg(S1, Name, InsertBefore); } /// Replace 0-X with X*-1. @@ -914,7 +914,7 @@ // Insert a 'neg' instruction that subtracts the value from zero to get the // negation. - BinaryOperator *NewNeg = CreateNeg(V, V->getName() + ".neg", BI, BI); + Instruction *NewNeg = CreateNeg(V, V->getName() + ".neg", BI, BI); ToRedo.insert(NewNeg); return NewNeg; } diff --git a/llvm/test/Transforms/InstCombine/cos-sin-intrinsic.ll b/llvm/test/Transforms/InstCombine/cos-sin-intrinsic.ll --- a/llvm/test/Transforms/InstCombine/cos-sin-intrinsic.ll +++ b/llvm/test/Transforms/InstCombine/cos-sin-intrinsic.ll @@ -151,7 +151,7 @@ define <2 x float> @fneg_sin(<2 x float> %x){ ; CHECK-LABEL: @fneg_sin( ; CHECK-NEXT: [[TMP1:%.*]] = call <2 x float> @llvm.sin.v2f32(<2 x float> [[X:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub <2 x float> , [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg <2 x float> [[TMP1]] ; CHECK-NEXT: ret <2 x float> [[R]] ; %negx = fsub <2 x float> , %x @@ -162,7 +162,7 @@ define <2 x float> @unary_fneg_sin(<2 x float> %x){ ; CHECK-LABEL: @unary_fneg_sin( ; CHECK-NEXT: [[TMP1:%.*]] = call <2 x float> @llvm.sin.v2f32(<2 x float> [[X:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub <2 x float> , [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg <2 x float> [[TMP1]] ; CHECK-NEXT: ret <2 x float> [[R]] ; %negx = fneg <2 x float> %x @@ -175,7 +175,7 @@ define <2 x float> @fneg_sin_fmf(<2 x float> %x){ ; CHECK-LABEL: @fneg_sin_fmf( ; CHECK-NEXT: [[TMP1:%.*]] = call nnan arcp afn <2 x float> @llvm.sin.v2f32(<2 x float> [[X:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub nnan arcp afn <2 x float> , [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg nnan arcp afn <2 x float> [[TMP1]] ; CHECK-NEXT: ret <2 x float> [[R]] ; %negx = fsub fast <2 x float> , %x @@ -186,7 +186,7 @@ define <2 x float> @unary_fneg_sin_fmf(<2 x float> %x){ ; CHECK-LABEL: @unary_fneg_sin_fmf( ; CHECK-NEXT: [[TMP1:%.*]] = call nnan arcp afn <2 x float> @llvm.sin.v2f32(<2 x float> [[X:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub nnan arcp afn <2 x float> , [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg nnan arcp afn <2 x float> [[TMP1]] ; CHECK-NEXT: ret <2 x float> [[R]] ; %negx = fneg fast <2 x float> %x diff --git a/llvm/test/Transforms/InstCombine/fast-math.ll b/llvm/test/Transforms/InstCombine/fast-math.ll --- a/llvm/test/Transforms/InstCombine/fast-math.ll +++ b/llvm/test/Transforms/InstCombine/fast-math.ll @@ -269,7 +269,7 @@ define float @fsub_fadd_common_op_fneg(float %x, float %y) { ; CHECK-LABEL: @fsub_fadd_common_op_fneg( -; CHECK-NEXT: [[R:%.*]] = fsub fast float -0.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[R:%.*]] = fneg fast float [[X:%.*]] ; CHECK-NEXT: ret float [[R]] ; %a = fadd float %x, %y @@ -283,7 +283,7 @@ define float @fsub_fadd_common_op_fneg_reassoc_nsz(float %x, float %y) { ; CHECK-LABEL: @fsub_fadd_common_op_fneg_reassoc_nsz( -; CHECK-NEXT: [[R:%.*]] = fsub reassoc nsz float -0.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[R:%.*]] = fneg reassoc nsz float [[X:%.*]] ; CHECK-NEXT: ret float [[R]] ; %a = fadd float %x, %y @@ -295,7 +295,7 @@ define <2 x float> @fsub_fadd_common_op_fneg_vec(<2 x float> %x, <2 x float> %y) { ; CHECK-LABEL: @fsub_fadd_common_op_fneg_vec( -; CHECK-NEXT: [[R:%.*]] = fsub reassoc nsz <2 x float> , [[X:%.*]] +; CHECK-NEXT: [[R:%.*]] = fneg reassoc nsz <2 x float> [[X:%.*]] ; CHECK-NEXT: ret <2 x float> [[R]] ; %a = fadd <2 x float> %x, %y @@ -308,7 +308,7 @@ define float @fsub_fadd_common_op_fneg_commute(float %x, float %y) { ; CHECK-LABEL: @fsub_fadd_common_op_fneg_commute( -; CHECK-NEXT: [[R:%.*]] = fsub reassoc nsz float -0.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[R:%.*]] = fneg reassoc nsz float [[X:%.*]] ; CHECK-NEXT: ret float [[R]] ; %a = fadd float %y, %x @@ -320,7 +320,7 @@ define <2 x float> @fsub_fadd_common_op_fneg_commute_vec(<2 x float> %x, <2 x float> %y) { ; CHECK-LABEL: @fsub_fadd_common_op_fneg_commute_vec( -; CHECK-NEXT: [[R:%.*]] = fsub reassoc nsz <2 x float> , [[X:%.*]] +; CHECK-NEXT: [[R:%.*]] = fneg reassoc nsz <2 x float> [[X:%.*]] ; CHECK-NEXT: ret <2 x float> [[R]] ; %a = fadd <2 x float> %y, %x @@ -333,7 +333,7 @@ define float @fsub_fsub_common_op_fneg(float %x, float %y) { ; CHECK-LABEL: @fsub_fsub_common_op_fneg( -; CHECK-NEXT: [[R:%.*]] = fsub reassoc nsz float -0.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[R:%.*]] = fneg reassoc nsz float [[X:%.*]] ; CHECK-NEXT: ret float [[R]] ; %s = fsub float %y, %x @@ -345,7 +345,7 @@ define <2 x float> @fsub_fsub_common_op_fneg_vec(<2 x float> %x, <2 x float> %y) { ; CHECK-LABEL: @fsub_fsub_common_op_fneg_vec( -; CHECK-NEXT: [[R:%.*]] = fsub reassoc nsz <2 x float> , [[X:%.*]] +; CHECK-NEXT: [[R:%.*]] = fneg reassoc nsz <2 x float> [[X:%.*]] ; CHECK-NEXT: ret <2 x float> [[R]] ; %s = fsub <2 x float> %y, %x @@ -534,7 +534,7 @@ define float @fneg2(float %x) { ; CHECK-LABEL: @fneg2( -; CHECK-NEXT: [[SUB:%.*]] = fsub nsz float -0.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[SUB:%.*]] = fneg nsz float [[X:%.*]] ; CHECK-NEXT: ret float [[SUB]] ; %sub = fsub nsz float 0.0, %x @@ -543,7 +543,7 @@ define <2 x float> @fneg2_vec_undef(<2 x float> %x) { ; CHECK-LABEL: @fneg2_vec_undef( -; CHECK-NEXT: [[SUB:%.*]] = fsub nsz <2 x float> , [[X:%.*]] +; CHECK-NEXT: [[SUB:%.*]] = fneg nsz <2 x float> [[X:%.*]] ; CHECK-NEXT: ret <2 x float> [[SUB]] ; %sub = fsub nsz <2 x float> , %x diff --git a/llvm/test/Transforms/InstCombine/fmul.ll b/llvm/test/Transforms/InstCombine/fmul.ll --- a/llvm/test/Transforms/InstCombine/fmul.ll +++ b/llvm/test/Transforms/InstCombine/fmul.ll @@ -336,7 +336,7 @@ ; (0.0 - X) * Y define float @neg_sink_nsz(float %x, float %y) { ; CHECK-LABEL: @neg_sink_nsz( -; CHECK-NEXT: [[SUB1:%.*]] = fsub nsz float -0.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[SUB1:%.*]] = fneg nsz float [[X:%.*]] ; CHECK-NEXT: [[MUL:%.*]] = fmul float [[SUB1]], [[Y:%.*]] ; CHECK-NEXT: ret float [[MUL]] ; @@ -409,7 +409,7 @@ ; X * -1.0 => -0.0 - X define float @test9(float %x) { ; CHECK-LABEL: @test9( -; CHECK-NEXT: [[MUL:%.*]] = fsub float -0.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[MUL:%.*]] = fneg float [[X:%.*]] ; CHECK-NEXT: ret float [[MUL]] ; %mul = fmul float %x, -1.0 @@ -419,7 +419,7 @@ ; PR18532 define <4 x float> @test10(<4 x float> %x) { ; CHECK-LABEL: @test10( -; CHECK-NEXT: [[MUL:%.*]] = fsub arcp afn <4 x float> , [[X:%.*]] +; CHECK-NEXT: [[MUL:%.*]] = fneg arcp afn <4 x float> [[X:%.*]] ; CHECK-NEXT: ret <4 x float> [[MUL]] ; %mul = fmul arcp afn <4 x float> %x, diff --git a/llvm/test/Transforms/InstCombine/fneg.ll b/llvm/test/Transforms/InstCombine/fneg.ll --- a/llvm/test/Transforms/InstCombine/fneg.ll +++ b/llvm/test/Transforms/InstCombine/fneg.ll @@ -349,7 +349,7 @@ ; CHECK-NEXT: [[N1:%.*]] = fsub float -0.000000e+00, [[X:%.*]] ; CHECK-NEXT: call void @use(float [[N1]]) ; CHECK-NEXT: [[SEL_V:%.*]] = select i1 [[COND:%.*]], float [[X]], float [[Y:%.*]] -; CHECK-NEXT: [[SEL:%.*]] = fsub float -0.000000e+00, [[SEL_V]] +; CHECK-NEXT: [[SEL:%.*]] = fneg float [[SEL_V]] ; CHECK-NEXT: ret float [[SEL]] ; %n1 = fsub float -0.0, %x diff --git a/llvm/test/Transforms/InstCombine/fpcast.ll b/llvm/test/Transforms/InstCombine/fpcast.ll --- a/llvm/test/Transforms/InstCombine/fpcast.ll +++ b/llvm/test/Transforms/InstCombine/fpcast.ll @@ -32,7 +32,7 @@ define half @fneg_fptrunc(float %a) { ; CHECK-LABEL: @fneg_fptrunc( ; CHECK-NEXT: [[TMP1:%.*]] = fptrunc float [[A:%.*]] to half -; CHECK-NEXT: [[C:%.*]] = fsub half 0xH8000, [[TMP1]] +; CHECK-NEXT: [[C:%.*]] = fneg half [[TMP1]] ; CHECK-NEXT: ret half [[C]] ; %b = fsub float -0.0, %a @@ -54,7 +54,7 @@ define <2 x half> @fneg_fptrunc_vec_undef(<2 x float> %a) { ; CHECK-LABEL: @fneg_fptrunc_vec_undef( ; CHECK-NEXT: [[TMP1:%.*]] = fptrunc <2 x float> [[A:%.*]] to <2 x half> -; CHECK-NEXT: [[C:%.*]] = fsub <2 x half> , [[TMP1]] +; CHECK-NEXT: [[C:%.*]] = fneg <2 x half> [[TMP1]] ; CHECK-NEXT: ret <2 x half> [[C]] ; %b = fsub <2 x float> , %a @@ -76,7 +76,7 @@ define half @test4-fast(float %a) { ; CHECK-LABEL: @test4-fast( ; CHECK-NEXT: [[TMP1:%.*]] = fptrunc float [[A:%.*]] to half -; CHECK-NEXT: [[C:%.*]] = fsub fast half 0xH8000, [[TMP1]] +; CHECK-NEXT: [[C:%.*]] = fneg fast half [[TMP1]] ; CHECK-NEXT: ret half [[C]] ; %b = fsub fast float -0.0, %a diff --git a/llvm/test/Transforms/InstCombine/fsub.ll b/llvm/test/Transforms/InstCombine/fsub.ll --- a/llvm/test/Transforms/InstCombine/fsub.ll +++ b/llvm/test/Transforms/InstCombine/fsub.ll @@ -331,7 +331,7 @@ define float @neg_trunc_op1_extra_use(double %a, float %b) { ; CHECK-LABEL: @neg_trunc_op1_extra_use( ; CHECK-NEXT: [[TMP1:%.*]] = fptrunc double [[A:%.*]] to float -; CHECK-NEXT: [[T2:%.*]] = fsub float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[T2:%.*]] = fneg float [[TMP1]] ; CHECK-NEXT: [[T3:%.*]] = fadd float [[TMP1]], [[B:%.*]] ; CHECK-NEXT: call void @use(float [[T2]]) ; CHECK-NEXT: ret float [[T3]] diff --git a/llvm/test/Transforms/InstCombine/maximum.ll b/llvm/test/Transforms/InstCombine/maximum.ll --- a/llvm/test/Transforms/InstCombine/maximum.ll +++ b/llvm/test/Transforms/InstCombine/maximum.ll @@ -217,7 +217,7 @@ define <2 x float> @neg_neg(<2 x float> %x, <2 x float> %y) { ; CHECK-LABEL: @neg_neg( ; CHECK-NEXT: [[TMP1:%.*]] = call <2 x float> @llvm.minimum.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub <2 x float> , [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg <2 x float> [[TMP1]] ; CHECK-NEXT: ret <2 x float> [[R]] ; %negx = fsub <2 x float> , %x @@ -229,7 +229,7 @@ define <2 x float> @unary_neg_neg(<2 x float> %x, <2 x float> %y) { ; CHECK-LABEL: @unary_neg_neg( ; CHECK-NEXT: [[TMP1:%.*]] = call <2 x float> @llvm.minimum.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub <2 x float> , [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg <2 x float> [[TMP1]] ; CHECK-NEXT: ret <2 x float> [[R]] ; %negx = fneg <2 x float> %x @@ -243,7 +243,7 @@ define float @neg_neg_vec_fmf(float %x, float %y) { ; CHECK-LABEL: @neg_neg_vec_fmf( ; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.minimum.f32(float [[X:%.*]], float [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub fast float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg fast float [[TMP1]] ; CHECK-NEXT: ret float [[R]] ; %negx = fsub arcp float -0.0, %x @@ -255,7 +255,7 @@ define float @unary_neg_neg_vec_fmf(float %x, float %y) { ; CHECK-LABEL: @unary_neg_neg_vec_fmf( ; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.minimum.f32(float [[X:%.*]], float [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub fast float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg fast float [[TMP1]] ; CHECK-NEXT: ret float [[R]] ; %negx = fneg arcp float %x @@ -272,7 +272,7 @@ ; CHECK-LABEL: @neg_neg_extra_use_x( ; CHECK-NEXT: [[NEGX:%.*]] = fsub float -0.000000e+00, [[X:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minimum.f32(float [[X]], float [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg float [[TMP1]] ; CHECK-NEXT: call void @use(float [[NEGX]]) ; CHECK-NEXT: ret float [[R]] ; @@ -287,7 +287,7 @@ ; CHECK-LABEL: @unary_neg_neg_extra_use_x( ; CHECK-NEXT: [[NEGX:%.*]] = fneg float [[X:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minimum.f32(float [[X]], float [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg float [[TMP1]] ; CHECK-NEXT: call void @use(float [[NEGX]]) ; CHECK-NEXT: ret float [[R]] ; @@ -302,7 +302,7 @@ ; CHECK-LABEL: @neg_neg_extra_use_y( ; CHECK-NEXT: [[NEGY:%.*]] = fsub float -0.000000e+00, [[Y:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float [[Y]]) -; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg float [[TMP1]] ; CHECK-NEXT: call void @use(float [[NEGY]]) ; CHECK-NEXT: ret float [[R]] ; @@ -317,7 +317,7 @@ ; CHECK-LABEL: @unary_neg_neg_extra_use_y( ; CHECK-NEXT: [[NEGY:%.*]] = fneg float [[Y:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minimum.f32(float [[X:%.*]], float [[Y]]) -; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg float [[TMP1]] ; CHECK-NEXT: call void @use(float [[NEGY]]) ; CHECK-NEXT: ret float [[R]] ; diff --git a/llvm/test/Transforms/InstCombine/maxnum.ll b/llvm/test/Transforms/InstCombine/maxnum.ll --- a/llvm/test/Transforms/InstCombine/maxnum.ll +++ b/llvm/test/Transforms/InstCombine/maxnum.ll @@ -223,7 +223,7 @@ define <2 x float> @neg_neg(<2 x float> %x, <2 x float> %y) { ; CHECK-LABEL: @neg_neg( ; CHECK-NEXT: [[TMP1:%.*]] = call <2 x float> @llvm.minnum.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub <2 x float> , [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg <2 x float> [[TMP1]] ; CHECK-NEXT: ret <2 x float> [[R]] ; %negx = fsub <2 x float> , %x @@ -237,7 +237,7 @@ define float @neg_neg_vec_fmf(float %x, float %y) { ; CHECK-LABEL: @neg_neg_vec_fmf( ; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub fast float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg fast float [[TMP1]] ; CHECK-NEXT: ret float [[R]] ; %negx = fsub arcp float -0.0, %x @@ -249,7 +249,7 @@ define float @unary_neg_neg_vec_fmf(float %x, float %y) { ; CHECK-LABEL: @unary_neg_neg_vec_fmf( ; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.minnum.f32(float [[X:%.*]], float [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub fast float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg fast float [[TMP1]] ; CHECK-NEXT: ret float [[R]] ; %negx = fneg arcp float %x @@ -266,7 +266,7 @@ ; CHECK-LABEL: @neg_neg_extra_use_x( ; CHECK-NEXT: [[NEGX:%.*]] = fsub float -0.000000e+00, [[X:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minnum.f32(float [[X]], float [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg float [[TMP1]] ; CHECK-NEXT: call void @use(float [[NEGX]]) ; CHECK-NEXT: ret float [[R]] ; @@ -281,7 +281,7 @@ ; CHECK-LABEL: @unary_neg_neg_extra_use_x( ; CHECK-NEXT: [[NEGX:%.*]] = fneg float [[X:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minnum.f32(float [[X]], float [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg float [[TMP1]] ; CHECK-NEXT: call void @use(float [[NEGX]]) ; CHECK-NEXT: ret float [[R]] ; @@ -296,7 +296,7 @@ ; CHECK-LABEL: @neg_neg_extra_use_y( ; CHECK-NEXT: [[NEGY:%.*]] = fsub float -0.000000e+00, [[Y:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y]]) -; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg float [[TMP1]] ; CHECK-NEXT: call void @use(float [[NEGY]]) ; CHECK-NEXT: ret float [[R]] ; @@ -311,7 +311,7 @@ ; CHECK-LABEL: @unary_neg_neg_extra_use_y( ; CHECK-NEXT: [[NEGY:%.*]] = fneg float [[Y:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call float @llvm.minnum.f32(float [[X:%.*]], float [[Y]]) -; CHECK-NEXT: [[R:%.*]] = fsub float -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg float [[TMP1]] ; CHECK-NEXT: call void @use(float [[NEGY]]) ; CHECK-NEXT: ret float [[R]] ; diff --git a/llvm/test/Transforms/InstCombine/minimum.ll b/llvm/test/Transforms/InstCombine/minimum.ll --- a/llvm/test/Transforms/InstCombine/minimum.ll +++ b/llvm/test/Transforms/InstCombine/minimum.ll @@ -241,7 +241,7 @@ define double @neg_neg(double %x, double %y) { ; CHECK-LABEL: @neg_neg( ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maximum.f64(double [[X:%.*]], double [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: ret double [[R]] ; %negx = fsub double -0.0, %x @@ -253,7 +253,7 @@ define double @unary_neg_neg(double %x, double %y) { ; CHECK-LABEL: @unary_neg_neg( ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maximum.f64(double [[X:%.*]], double [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: ret double [[R]] ; %negx = fneg double %x @@ -268,7 +268,7 @@ define <2 x double> @neg_neg_vec_fmf(<2 x double> %x, <2 x double> %y) { ; CHECK-LABEL: @neg_neg_vec_fmf( ; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf <2 x double> @llvm.maximum.v2f64(<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub nnan ninf <2 x double> , [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg nnan ninf <2 x double> [[TMP1]] ; CHECK-NEXT: ret <2 x double> [[R]] ; %negx = fsub reassoc <2 x double> , %x @@ -280,7 +280,7 @@ define <2 x double> @unary_neg_neg_vec_fmf(<2 x double> %x, <2 x double> %y) { ; CHECK-LABEL: @unary_neg_neg_vec_fmf( ; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf <2 x double> @llvm.maximum.v2f64(<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub nnan ninf <2 x double> , [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg nnan ninf <2 x double> [[TMP1]] ; CHECK-NEXT: ret <2 x double> [[R]] ; %negx = fneg reassoc <2 x double> %x @@ -297,7 +297,7 @@ ; CHECK-LABEL: @neg_neg_extra_use_x( ; CHECK-NEXT: [[NEGX:%.*]] = fsub double -0.000000e+00, [[X:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maximum.f64(double [[X]], double [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: call void @use(double [[NEGX]]) ; CHECK-NEXT: ret double [[R]] ; @@ -312,7 +312,7 @@ ; CHECK-LABEL: @unary_neg_neg_extra_use_x( ; CHECK-NEXT: [[NEGX:%.*]] = fneg double [[X:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maximum.f64(double [[X]], double [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: call void @use(double [[NEGX]]) ; CHECK-NEXT: ret double [[R]] ; @@ -327,7 +327,7 @@ ; CHECK-LABEL: @neg_neg_extra_use_y( ; CHECK-NEXT: [[NEGY:%.*]] = fsub double -0.000000e+00, [[Y:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maximum.f64(double [[X:%.*]], double [[Y]]) -; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: call void @use(double [[NEGY]]) ; CHECK-NEXT: ret double [[R]] ; @@ -342,7 +342,7 @@ ; CHECK-LABEL: @unary_neg_neg_extra_use_y( ; CHECK-NEXT: [[NEGY:%.*]] = fneg double [[Y:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maximum.f64(double [[X:%.*]], double [[Y]]) -; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: call void @use(double [[NEGY]]) ; CHECK-NEXT: ret double [[R]] ; diff --git a/llvm/test/Transforms/InstCombine/minmax-fp.ll b/llvm/test/Transforms/InstCombine/minmax-fp.ll --- a/llvm/test/Transforms/InstCombine/minmax-fp.ll +++ b/llvm/test/Transforms/InstCombine/minmax-fp.ll @@ -273,7 +273,7 @@ ; CHECK-LABEL: define {{[^@]+}}@fsub_fmax( ; CHECK-NEXT: [[COND_INV:%.*]] = fcmp nnan nsz ogt <2 x float> [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = select nnan nsz <2 x i1> [[COND_INV]], <2 x float> [[Y]], <2 x float> [[X]] -; CHECK-NEXT: [[MAX:%.*]] = fsub <2 x float> , [[TMP1]] +; CHECK-NEXT: [[MAX:%.*]] = fneg <2 x float> [[TMP1]] ; CHECK-NEXT: ret <2 x float> [[MAX]] ; %n1 = fsub <2 x float> , %x @@ -287,7 +287,7 @@ ; CHECK-LABEL: define {{[^@]+}}@fsub_fmin( ; CHECK-NEXT: [[COND:%.*]] = fcmp nnan ogt <2 x double> [[X:%.*]], [[Y:%.*]] ; CHECK-NEXT: [[MAX_V:%.*]] = select <2 x i1> [[COND]], <2 x double> [[X]], <2 x double> [[Y]] -; CHECK-NEXT: [[MAX:%.*]] = fsub <2 x double> , [[MAX_V]] +; CHECK-NEXT: [[MAX:%.*]] = fneg <2 x double> [[MAX_V]] ; CHECK-NEXT: ret <2 x double> [[MAX]] ; %n1 = fsub <2 x double> , %x diff --git a/llvm/test/Transforms/InstCombine/minnum.ll b/llvm/test/Transforms/InstCombine/minnum.ll --- a/llvm/test/Transforms/InstCombine/minnum.ll +++ b/llvm/test/Transforms/InstCombine/minnum.ll @@ -247,7 +247,7 @@ define double @neg_neg(double %x, double %y) { ; CHECK-LABEL: @neg_neg( ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: ret double [[R]] ; %negx = fsub double -0.0, %x @@ -259,7 +259,7 @@ define double @unary_neg_neg(double %x, double %y) { ; CHECK-LABEL: @unary_neg_neg( ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: ret double [[R]] ; %negx = fneg double %x @@ -274,7 +274,7 @@ define <2 x double> @neg_neg_vec_fmf(<2 x double> %x, <2 x double> %y) { ; CHECK-LABEL: @neg_neg_vec_fmf( ; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf <2 x double> @llvm.maxnum.v2f64(<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub nnan ninf <2 x double> , [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg nnan ninf <2 x double> [[TMP1]] ; CHECK-NEXT: ret <2 x double> [[R]] ; %negx = fsub reassoc <2 x double> , %x @@ -286,7 +286,7 @@ define <2 x double> @unary_neg_neg_vec_fmf(<2 x double> %x, <2 x double> %y) { ; CHECK-LABEL: @unary_neg_neg_vec_fmf( ; CHECK-NEXT: [[TMP1:%.*]] = call nnan ninf <2 x double> @llvm.maxnum.v2f64(<2 x double> [[X:%.*]], <2 x double> [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub nnan ninf <2 x double> , [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg nnan ninf <2 x double> [[TMP1]] ; CHECK-NEXT: ret <2 x double> [[R]] ; %negx = fneg reassoc <2 x double> %x @@ -303,7 +303,7 @@ ; CHECK-LABEL: @neg_neg_extra_use_x( ; CHECK-NEXT: [[NEGX:%.*]] = fsub double -0.000000e+00, [[X:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X]], double [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: call void @use(double [[NEGX]]) ; CHECK-NEXT: ret double [[R]] ; @@ -318,7 +318,7 @@ ; CHECK-LABEL: @unary_neg_neg_extra_use_x( ; CHECK-NEXT: [[NEGX:%.*]] = fneg double [[X:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X]], double [[Y:%.*]]) -; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: call void @use(double [[NEGX]]) ; CHECK-NEXT: ret double [[R]] ; @@ -333,7 +333,7 @@ ; CHECK-LABEL: @neg_neg_extra_use_y( ; CHECK-NEXT: [[NEGY:%.*]] = fsub double -0.000000e+00, [[Y:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y]]) -; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: call void @use(double [[NEGY]]) ; CHECK-NEXT: ret double [[R]] ; @@ -348,7 +348,7 @@ ; CHECK-LABEL: @unary_neg_neg_extra_use_y( ; CHECK-NEXT: [[NEGY:%.*]] = fneg double [[Y:%.*]] ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y]]) -; CHECK-NEXT: [[R:%.*]] = fsub double -0.000000e+00, [[TMP1]] +; CHECK-NEXT: [[R:%.*]] = fneg double [[TMP1]] ; CHECK-NEXT: call void @use(double [[NEGY]]) ; CHECK-NEXT: ret double [[R]] ; diff --git a/llvm/test/Transforms/InstCombine/pow-1.ll b/llvm/test/Transforms/InstCombine/pow-1.ll --- a/llvm/test/Transforms/InstCombine/pow-1.ll +++ b/llvm/test/Transforms/InstCombine/pow-1.ll @@ -170,7 +170,7 @@ define <2 x float> @test_simplify4vn(<2 x float> %x) { ; CHECK-LABEL: @test_simplify4vn( -; ANY-NEXT: [[MUL:%.*]] = fsub <2 x float> , [[X:%.*]] +; ANY-NEXT: [[MUL:%.*]] = fneg <2 x float> [[X:%.*]] ; ANY-NEXT: [[EXP2:%.*]] = call <2 x float> @llvm.exp2.v2f32(<2 x float> [[MUL]]) ; ANY-NEXT: ret <2 x float> [[EXP2]] ; MSVC-NEXT: [[POW:%.*]] = call <2 x float> @llvm.pow.v2f32(<2 x float> , <2 x float> [[X:%.*]]) diff --git a/llvm/test/Transforms/Reassociate/fast-basictest.ll b/llvm/test/Transforms/Reassociate/fast-basictest.ll --- a/llvm/test/Transforms/Reassociate/fast-basictest.ll +++ b/llvm/test/Transforms/Reassociate/fast-basictest.ll @@ -4,7 +4,7 @@ ; With reassociation, constant folding can eliminate the 12 and -12 constants. define float @test1(float %arg) { ; CHECK-LABEL: @test1( -; CHECK-NEXT: [[ARG_NEG:%.*]] = fsub fast float -0.000000e+00, [[ARG:%.*]] +; CHECK-NEXT: [[ARG_NEG:%.*]] = fneg fast float [[ARG:%.*]] ; CHECK-NEXT: ret float [[ARG_NEG]] ; %t1 = fsub fast float -1.200000e+01, %arg @@ -16,7 +16,7 @@ ; Both 'reassoc' and 'nsz' are required. define float @test1_minimal(float %arg) { ; CHECK-LABEL: @test1_minimal( -; CHECK-NEXT: [[TMP1:%.*]] = fsub reassoc nsz float -0.000000e+00, [[ARG:%.*]] +; CHECK-NEXT: [[TMP1:%.*]] = fneg reassoc nsz float [[ARG:%.*]] ; CHECK-NEXT: ret float [[TMP1]] ; %t1 = fsub reassoc nsz float -1.200000e+01, %arg diff --git a/llvm/test/Transforms/Reassociate/fp-expr.ll b/llvm/test/Transforms/Reassociate/fp-expr.ll --- a/llvm/test/Transforms/Reassociate/fp-expr.ll +++ b/llvm/test/Transforms/Reassociate/fp-expr.ll @@ -4,7 +4,7 @@ define void @test1() { ; CHECK-LABEL: @test1( ; CHECK-NEXT: [[T1:%.*]] = tail call <4 x float> @blam() -; CHECK-NEXT: [[T1_NEG:%.*]] = fsub fast <4 x float> , [[T1]] +; CHECK-NEXT: [[T1_NEG:%.*]] = fneg fast <4 x float> [[T1]] ; CHECK-NEXT: [[T24:%.*]] = fadd fast <4 x float> [[T1_NEG]], undef ; CHECK-NEXT: tail call void @wombat(<4 x float> [[T24]]) ; CHECK-NEXT: ret void @@ -19,7 +19,7 @@ define half @test2() { ; CHECK-LABEL: @test2( ; CHECK-NEXT: [[T15:%.*]] = fsub fast half undef, undef -; CHECK-NEXT: [[T15_NEG:%.*]] = fsub fast half 0xH8000, [[T15]] +; CHECK-NEXT: [[T15_NEG:%.*]] = fneg fast half [[T15]] ; CHECK-NEXT: [[T18:%.*]] = fadd fast half [[T15_NEG]], undef ; CHECK-NEXT: ret half [[T18]] ;