summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp4
-rw-r--r--llvm/test/Transforms/InstSimplify/call.ll6
2 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index d151b78f04c..22a76a05595 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -5091,7 +5091,9 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1,
if (Op0 == Op1)
return Op0;
// copysign -X, X --> X
- if (match(Op0, m_FNeg(m_Specific(Op1))))
+ // copysign X, -X --> -X
+ if (match(Op0, m_FNeg(m_Specific(Op1))) ||
+ match(Op1, m_FNeg(m_Specific(Op0))))
return Op1;
break;
case Intrinsic::maxnum:
diff --git a/llvm/test/Transforms/InstSimplify/call.ll b/llvm/test/Transforms/InstSimplify/call.ll
index a8a9bf54378..15c56d233e8 100644
--- a/llvm/test/Transforms/InstSimplify/call.ll
+++ b/llvm/test/Transforms/InstSimplify/call.ll
@@ -943,8 +943,7 @@ define <2 x double> @copysign_same_operand_vec(<2 x double> %x) {
define float @negated_sign_arg(float %x) {
; CHECK-LABEL: @negated_sign_arg(
; CHECK-NEXT: [[NEGX:%.*]] = fsub ninf float -0.000000e+00, [[X:%.*]]
-; CHECK-NEXT: [[R:%.*]] = call arcp float @llvm.copysign.f32(float [[X]], float [[NEGX]])
-; CHECK-NEXT: ret float [[R]]
+; CHECK-NEXT: ret float [[NEGX]]
;
%negx = fsub ninf float -0.0, %x
%r = call arcp float @llvm.copysign.f32(float %x, float %negx)
@@ -954,8 +953,7 @@ define float @negated_sign_arg(float %x) {
define <2 x double> @negated_sign_arg_vec(<2 x double> %x) {
; CHECK-LABEL: @negated_sign_arg_vec(
; CHECK-NEXT: [[NEGX:%.*]] = fneg afn <2 x double> [[X:%.*]]
-; CHECK-NEXT: [[R:%.*]] = call arcp <2 x double> @llvm.copysign.v2f64(<2 x double> [[X]], <2 x double> [[NEGX]])
-; CHECK-NEXT: ret <2 x double> [[R]]
+; CHECK-NEXT: ret <2 x double> [[NEGX]]
;
%negx = fneg afn <2 x double> %x
%r = call arcp <2 x double> @llvm.copysign.v2f64(<2 x double> %x, <2 x double> %negx)
OpenPOWER on IntegriCloud