[InstSimplify] reduce code for FP undef/nan folding; NFC
authorSanjay Patel <spatel@rotateright.com>
Thu, 12 Mar 2020 12:45:38 +0000 (08:45 -0400)
committerSanjay Patel <spatel@rotateright.com>
Thu, 12 Mar 2020 12:46:15 +0000 (08:46 -0400)
llvm/lib/Analysis/InstructionSimplify.cpp

index ef3ae1f..073ddb4 100644 (file)
@@ -4604,13 +4604,10 @@ static Constant *propagateNaN(Constant *In) {
 /// transforms based on undef/NaN because the operation itself makes no
 /// difference to the result.
 static Constant *simplifyFPOp(ArrayRef<Value *> Ops) {
-  if (any_of(Ops, [](Value *V) { return isa<UndefValue>(V); }))
-    return ConstantFP::getNaN(Ops[0]->getType());
-
-  for (Value *V : Ops)
-    if (match(V, m_NaN()))
+  for (Value *V : Ops) {
+    if (match(V, m_Undef()) || match(V, m_NaN()))
       return propagateNaN(cast<Constant>(V));
-
+  }
   return nullptr;
 }