Skip to content

Commit

Permalink
Remove BinaryOperator::CreateFNeg
Browse files Browse the repository at this point in the history
Use UnaryOperator::CreateFNeg instead.

Summary:
With the introduction of the native fneg instruction, the
fsub -0.0, %x idiom is obsolete. This patch makes LLVM
emit fneg instead of the idiom in all places.

Reviewed By: cameron.mcinally

Differential Revision: https://reviews.llvm.org/D75130
  • Loading branch information
simoll committed Feb 27, 2020
1 parent 740ed61 commit ddd1127
Show file tree
Hide file tree
Showing 23 changed files with 87 additions and 108 deletions.
6 changes: 3 additions & 3 deletions clang/test/CodeGen/complex-math.c
Expand Up @@ -149,7 +149,7 @@ float _Complex div_float_rc(float a, float _Complex b) {
// 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]]
Expand Down Expand Up @@ -327,7 +327,7 @@ double _Complex div_double_rc(double a, double _Complex b) {
// 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]]
Expand Down Expand Up @@ -523,7 +523,7 @@ long double _Complex div_long_double_rc(long double a, long double _Complex b) {
// 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]]
Expand Down
25 changes: 9 additions & 16 deletions llvm/include/llvm/IR/InstrTypes.h
Expand Up @@ -154,18 +154,20 @@ class UnaryOperator : public UnaryInstruction {
}
#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 {
Expand Down Expand Up @@ -280,11 +282,6 @@ class BinaryOperator : public Instruction {
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 = "") {
Expand Down Expand Up @@ -390,10 +387,6 @@ class BinaryOperator : public Instruction {
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,
Expand Down
14 changes: 0 additions & 14 deletions llvm/lib/IR/Instructions.cpp
Expand Up @@ -2393,20 +2393,6 @@ BinaryOperator *BinaryOperator::CreateNUWNeg(Value *Op, const Twine &Name,
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());
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
Expand Up @@ -2136,7 +2136,7 @@ Instruction *InstCombiner::visitFSub(BinaryOperator &I) {
// 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;
Expand Down Expand Up @@ -2214,12 +2214,12 @@ Instruction *InstCombiner::visitFSub(BinaryOperator &I) {
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)))) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
Expand Up @@ -2189,7 +2189,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
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;
}
Expand Down Expand Up @@ -2354,7 +2354,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
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;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
Expand Up @@ -1639,7 +1639,7 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &FPT) {
// FIXME: Once we're sure that unary FNeg optimizations are on par with
// binary FNeg, this should always return a unary operator.
if (isa<BinaryOperator>(Op))
return BinaryOperator::CreateFNegFMF(InnerTrunc, Op);
return UnaryOperator::CreateFNegFMF(InnerTrunc, Op);
return UnaryOperator::CreateFNegFMF(InnerTrunc, Op);
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
Expand Up @@ -411,7 +411,7 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
// 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;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
Expand Up @@ -341,7 +341,7 @@ Instruction *InstCombiner::foldSelectOpOp(SelectInst &SI, Instruction *TI,
// 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<BinaryOperator>(TI));
return UnaryOperator::CreateFNegFMF(NewSel, cast<BinaryOperator>(TI));
return UnaryOperator::CreateFNeg(NewSel);
}

Expand Down
16 changes: 8 additions & 8 deletions llvm/lib/Transforms/Scalar/Reassociate.cpp
Expand Up @@ -254,15 +254,15 @@ static BinaryOperator *CreateMul(Value *S1, Value *S2, const Twine &Name,
}
}

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<FPMathOperator>(FlagsOp)->getFastMathFlags());
return Res;
}

if (auto *FMFSource = dyn_cast<Instruction>(FlagsOp))
return UnaryOperator::CreateFNegFMF(S1, FMFSource, Name, InsertBefore);

return UnaryOperator::CreateFNeg(S1, Name, InsertBefore);
}

/// Replace 0-X with X*-1.
Expand Down Expand Up @@ -914,7 +914,7 @@ static Value *NegateValue(Value *V, Instruction *BI,

// 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;
}
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/Transforms/InstCombine/cos-sin-intrinsic.ll
Expand Up @@ -151,7 +151,7 @@ declare <2 x float> @llvm.sin.v2f32(<2 x float>)
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> <float -0.000000e+00, float -0.000000e+00>, [[TMP1]]
; CHECK-NEXT: [[R:%.*]] = fneg <2 x float> [[TMP1]]
; CHECK-NEXT: ret <2 x float> [[R]]
;
%negx = fsub <2 x float> <float -0.0, float -0.0>, %x
Expand All @@ -162,7 +162,7 @@ define <2 x float> @fneg_sin(<2 x float> %x){
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> <float -0.000000e+00, float -0.000000e+00>, [[TMP1]]
; CHECK-NEXT: [[R:%.*]] = fneg <2 x float> [[TMP1]]
; CHECK-NEXT: ret <2 x float> [[R]]
;
%negx = fneg <2 x float> %x
Expand All @@ -175,7 +175,7 @@ define <2 x float> @unary_fneg_sin(<2 x float> %x){
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> <float -0.000000e+00, float -0.000000e+00>, [[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> <float -0.0, float -0.0>, %x
Expand All @@ -186,7 +186,7 @@ define <2 x float> @fneg_sin_fmf(<2 x float> %x){
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> <float -0.000000e+00, float -0.000000e+00>, [[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
Expand Down
18 changes: 9 additions & 9 deletions llvm/test/Transforms/InstCombine/fast-math.ll
Expand Up @@ -269,7 +269,7 @@ define float @fold8_reassoc(float %f1) {

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
Expand All @@ -283,7 +283,7 @@ define float @fsub_fadd_common_op_fneg(float %x, float %y) {

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
Expand All @@ -295,7 +295,7 @@ define float @fsub_fadd_common_op_fneg_reassoc_nsz(float %x, float %y) {

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> <float -0.000000e+00, float -0.000000e+00>, [[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
Expand All @@ -308,7 +308,7 @@ define <2 x float> @fsub_fadd_common_op_fneg_vec(<2 x float> %x, <2 x float> %y)

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
Expand All @@ -320,7 +320,7 @@ define float @fsub_fadd_common_op_fneg_commute(float %x, float %y) {

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> <float -0.000000e+00, float -0.000000e+00>, [[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
Expand All @@ -333,7 +333,7 @@ define <2 x float> @fsub_fadd_common_op_fneg_commute_vec(<2 x float> %x, <2 x fl

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
Expand All @@ -345,7 +345,7 @@ define float @fsub_fsub_common_op_fneg(float %x, float %y) {

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> <float -0.000000e+00, float -0.000000e+00>, [[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
Expand Down Expand Up @@ -534,7 +534,7 @@ define float @fneg1(float %f1, float %f2) {

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
Expand All @@ -543,7 +543,7 @@ define float @fneg2(float %x) {

define <2 x float> @fneg2_vec_undef(<2 x float> %x) {
; CHECK-LABEL: @fneg2_vec_undef(
; CHECK-NEXT: [[SUB:%.*]] = fsub nsz <2 x float> <float -0.000000e+00, float -0.000000e+00>, [[X:%.*]]
; CHECK-NEXT: [[SUB:%.*]] = fneg nsz <2 x float> [[X:%.*]]
; CHECK-NEXT: ret <2 x float> [[SUB]]
;
%sub = fsub nsz <2 x float> <float undef, float 0.0>, %x
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Transforms/InstCombine/fmul.ll
Expand Up @@ -336,7 +336,7 @@ define <2 x float> @neg_mul_vec_undef(<2 x float> %x, <2 x float> %y) {
; (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]]
;
Expand Down Expand Up @@ -409,7 +409,7 @@ for.end: ; preds = %for.cond
; 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
Expand All @@ -419,7 +419,7 @@ define float @test9(float %x) {
; PR18532
define <4 x float> @test10(<4 x float> %x) {
; CHECK-LABEL: @test10(
; CHECK-NEXT: [[MUL:%.*]] = fsub arcp afn <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, [[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, <float -1.0, float -1.0, float -1.0, float -1.0>
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/InstCombine/fneg.ll
Expand Up @@ -349,7 +349,7 @@ define float @fsub_fsub_sel_extra_use1(float %x, float %y, i1 %cond) {
; 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
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Transforms/InstCombine/fpcast.ll
Expand Up @@ -32,7 +32,7 @@ define half @test3(float %a) {
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
Expand All @@ -54,7 +54,7 @@ define half @unary_fneg_fptrunc(float %a) {
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> <half 0xH8000, half 0xH8000>, [[TMP1]]
; CHECK-NEXT: [[C:%.*]] = fneg <2 x half> [[TMP1]]
; CHECK-NEXT: ret <2 x half> [[C]]
;
%b = fsub <2 x float> <float -0.0, float undef>, %a
Expand All @@ -76,7 +76,7 @@ define <2 x half> @unary_fneg_fptrunc_vec(<2 x float> %a) {
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
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/InstCombine/fsub.ll
Expand Up @@ -331,7 +331,7 @@ define float @unary_neg_ext_op1_extra_use(half %a, float %b) {
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]]
Expand Down

0 comments on commit ddd1127

Please sign in to comment.