summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-08-02 14:33:40 +0000
committerSanjay Patel <spatel@rotateright.com>2018-08-02 14:33:40 +0000
commit3f6e9a71f7dee5e44b5d6dae16d7a31163f9d7c1 (patch)
tree2b3c0f363b6851247a66fa8aac249831eaf60b7b /llvm/lib
parenta7dbe571e686f3a8f0d97715a82a6dc648a8d3db (diff)
downloadbcm5719-llvm-3f6e9a71f7dee5e44b5d6dae16d7a31163f9d7c1.tar.gz
bcm5719-llvm-3f6e9a71f7dee5e44b5d6dae16d7a31163f9d7c1.zip
[InstSimplify] move minnum/maxnum with undef fold from instcombine
llvm-svn: 338719
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp7
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp11
2 files changed, 4 insertions, 14 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index b1601bfe1b2..ffdbfc45c84 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4767,9 +4767,10 @@ static Value *simplifyBinaryIntrinsic(Function *F, Value *Op0, Value *Op1,
// 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;
+ // If one argument is NaN or undef, return the other argument.
+ if (match(Op0, m_CombineOr(m_NaN(), m_Undef()))) return Op1;
+ if (match(Op1, m_CombineOr(m_NaN(), m_Undef()))) return Op0;
+
break;
default:
break;
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 77c5a06ee11..748cb97d9b5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1143,17 +1143,6 @@ static Value *simplifyMinnumMaxnum(const IntrinsicInst &II) {
if (C1 && C1->isNaN())
return Arg0;
- // This is the value because if undef were NaN, we would return the other
- // value and cannot return a NaN unless both operands are.
- //
- // fmin(undef, x) -> x
- if (isa<UndefValue>(Arg0))
- return Arg1;
-
- // fmin(x, undef) -> x
- if (isa<UndefValue>(Arg1))
- return Arg0;
-
Value *X = nullptr;
Value *Y = nullptr;
if (II.getIntrinsicID() == Intrinsic::minnum) {
OpenPOWER on IntegriCloud