summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-03-18 14:32:54 +0000
committerSanjay Patel <spatel@rotateright.com>2018-03-18 14:32:54 +0000
commit63b1028953cf688c687fc5f3168ab948a50fcc54 (patch)
treecddd88adecca28ce4a8069b5cc6a4a3c9ad18cee /llvm/lib
parent95ec4a4dfe4655044a5f689f792e5394d73ea248 (diff)
downloadbcm5719-llvm-63b1028953cf688c687fc5f3168ab948a50fcc54.tar.gz
bcm5719-llvm-63b1028953cf688c687fc5f3168ab948a50fcc54.zip
[InstCombine] add nnan requirement for sqrt(x) * sqrt(y) -> sqrt(x*y)
This is similar to D43765. llvm-svn: 327797
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index 56de5ed006d..f35311bb966 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -636,7 +636,9 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
}
// sqrt(X) * sqrt(Y) -> sqrt(X * Y)
- if (I.hasAllowReassoc() &&
+ // nnan disallows the possibility of returning a number if both operands are
+ // negative (in that case, we should return NaN).
+ if (I.hasAllowReassoc() && I.hasNoNaNs() &&
match(Op0, m_OneUse(m_Intrinsic<Intrinsic::sqrt>(m_Value(X)))) &&
match(Op1, m_OneUse(m_Intrinsic<Intrinsic::sqrt>(m_Value(Y))))) {
Value *XY = Builder.CreateFMulFMF(X, Y, &I);
OpenPOWER on IntegriCloud