summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-12-08 10:05:28 -0500
committerSanjay Patel <spatel@rotateright.com>2019-12-08 10:08:02 -0500
commit12f39e0fede92ca04c811660530e750585124ed2 (patch)
tree12ec331edc3c97eb16e95a3cdb0e8fd6dd6e40b5 /llvm/lib/Analysis
parentb32490270b786d2c5ba154e613ee2d5e36ed4197 (diff)
downloadbcm5719-llvm-12f39e0fede92ca04c811660530e750585124ed2.tar.gz
bcm5719-llvm-12f39e0fede92ca04c811660530e750585124ed2.zip
[InstSimplify] fold copysign with negated operand
This is another transform suggested in PR44153: https://bugs.llvm.org/show_bug.cgi?id=44153 The backend for some targets already manages to get this if it converts copysign to bitwise logic.
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 7942cb09e84..d151b78f04c 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -5090,6 +5090,9 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1,
// copysign X, X --> X
if (Op0 == Op1)
return Op0;
+ // copysign -X, X --> X
+ if (match(Op0, m_FNeg(m_Specific(Op1))))
+ return Op1;
break;
case Intrinsic::maxnum:
case Intrinsic::minnum:
OpenPOWER on IntegriCloud