[llvm] dea2b93 - [InstSimplify] reduce code for FP undef/nan folding; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 12 05:46:23 PDT 2020


Author: Sanjay Patel
Date: 2020-03-12T08:46:15-04:00
New Revision: dea2b93a7b61dbc311cbc2748a16639f11dece32

URL: https://github.com/llvm/llvm-project/commit/dea2b93a7b61dbc311cbc2748a16639f11dece32
DIFF: https://github.com/llvm/llvm-project/commit/dea2b93a7b61dbc311cbc2748a16639f11dece32.diff

LOG: [InstSimplify] reduce code for FP undef/nan folding; NFC

Added: 
    

Modified: 
    llvm/lib/Analysis/InstructionSimplify.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index ef3ae1fddde1..073ddb40dc5c 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4604,13 +4604,10 @@ static Constant *propagateNaN(Constant *In) {
 /// transforms based on undef/NaN because the operation itself makes no
 /// 
diff erence 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;
 }
 


        


More information about the llvm-commits mailing list