diff options
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 4 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/maxnum.ll | 8 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/minnum.ll | 8 | ||||
-rw-r--r-- | llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll | 21 |
5 files changed, 22 insertions, 22 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 7fc7c15a0c2..b1601bfe1b2 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4764,6 +4764,9 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1, break; case Intrinsic::maxnum: case Intrinsic::minnum: + // If the arguments are the same, this is a no-op. + if (Op0 == Op1) return Op0; + // If one argument is NaN, return the other argument. if (match(Op0, m_NaN())) return Op1; if (match(Op1, m_NaN())) return Op0; diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index cbfbd8a5399..77c5a06ee11 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -1137,10 +1137,6 @@ static Value *simplifyMinnumMaxnum(const IntrinsicInst &II) { Value *Arg0 = II.getArgOperand(0); Value *Arg1 = II.getArgOperand(1); - // fmin(x, x) -> x - if (Arg0 == Arg1) - return Arg0; - const auto *C1 = dyn_cast<ConstantFP>(Arg1); // fmin(x, nan) -> x diff --git a/llvm/test/Transforms/InstCombine/maxnum.ll b/llvm/test/Transforms/InstCombine/maxnum.ll index 11bff42391a..ff415aa86f6 100644 --- a/llvm/test/Transforms/InstCombine/maxnum.ll +++ b/llvm/test/Transforms/InstCombine/maxnum.ll @@ -129,14 +129,6 @@ define float @canonicalize_constant_maxnum_f32(float %x) { ret float %y } -define float @noop_maxnum_f32(float %x) { -; CHECK-LABEL: @noop_maxnum_f32( -; CHECK-NEXT: ret float [[X:%.*]] -; - %y = call float @llvm.maxnum.f32(float %x, float %x) - ret float %y -} - define float @maxnum_f32_nan_val(float %x) { ; CHECK-LABEL: @maxnum_f32_nan_val( ; CHECK-NEXT: ret float [[X:%.*]] diff --git a/llvm/test/Transforms/InstCombine/minnum.ll b/llvm/test/Transforms/InstCombine/minnum.ll index a05ce8c545c..7cf9d1bc758 100644 --- a/llvm/test/Transforms/InstCombine/minnum.ll +++ b/llvm/test/Transforms/InstCombine/minnum.ll @@ -131,14 +131,6 @@ define float @canonicalize_constant_minnum_f32(float %x) { ret float %y } -define float @noop_minnum_f32(float %x) { -; CHECK-LABEL: @noop_minnum_f32( -; CHECK-NEXT: ret float [[X:%.*]] -; - %y = call float @llvm.minnum.f32(float %x, float %x) - ret float %y -} - define float @minnum_f32_nan_val(float %x) { ; CHECK-LABEL: @minnum_f32_nan_val( ; CHECK-NEXT: ret float [[X:%.*]] diff --git a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll index afd375f3b13..ca9226dd076 100644 --- a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll +++ b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll @@ -463,14 +463,15 @@ define float @fabs_select_positive_constants_vector_extract(i32 %c) { ret float %fabs } +declare float @llvm.minnum.f32(float, float) +declare float @llvm.maxnum.f32(float, float) declare double @llvm.minnum.f64(double, double) declare double @llvm.maxnum.f64(double, double) declare <2 x double> @llvm.minnum.v2f64(<2 x double>, <2 x double>) declare <2 x double> @llvm.maxnum.v2f64(<2 x double>, <2 x double>) ; From the LangRef for minnum/maxnum: -; "follows the IEEE-754 semantics for maxNum, which also match for libm’s fmax. -; If either operand is a NaN, returns the other non-NaN operand." +; "If either operand is a NaN, returns the other non-NaN operand." define double @maxnum_nan_op0(double %x) { ; CHECK-LABEL: @maxnum_nan_op0( @@ -536,3 +537,19 @@ define <2 x double> @minnum_nan_op1_vec(<2 x double> %x) { ret <2 x double> %r } +define float @minnum_same_args(float %x) { +; CHECK-LABEL: @minnum_same_args( +; CHECK-NEXT: ret float [[X:%.*]] +; + %y = call float @llvm.minnum.f32(float %x, float %x) + ret float %y +} + +define float @maxnum_same_args(float %x) { +; CHECK-LABEL: @maxnum_same_args( +; CHECK-NEXT: ret float [[X:%.*]] +; + %y = call float @llvm.maxnum.f32(float %x, float %x) + ret float %y +} + |