I misled Alkis: LLVM should have isnan, not isunordered.
authorChris Lattner <sabre@nondot.org>
Fri, 11 Jun 2004 02:29:43 +0000 (02:29 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 11 Jun 2004 02:29:43 +0000 (02:29 +0000)
  isunordered(X, Y) === isnan(X) | isnan(Y)

Remove isunordered, add isnan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14132 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Intrinsics.h
lib/CodeGen/IntrinsicLowering.cpp
lib/VMCore/Function.cpp
lib/VMCore/IntrinsicLowering.cpp
lib/VMCore/Verifier.cpp

index 56ecb4f1e61b8724a4a96a6f9b8240de1db8787c..8cca2cd32669e13e2f67e2c48e92dce6d7eb59b7 100644 (file)
@@ -59,7 +59,8 @@ namespace Intrinsic {
     memmove,        // Copy potentially overlapping memory blocks
     memset,         // Fill memory with a byte value
 
-    // Standard libm functions.
+    // libm related functions.
+    isnan,          // Return true if fp argument is a NAN.
 
     // Input/Output intrinsics.
     readport,
@@ -67,9 +68,6 @@ namespace Intrinsic {
     readio,
     writeio,
 
-    // Support for unordered compare intrinsic
-    isunordered,
-
     //===------------------------------------------------------------------===//
     // This section defines intrinsic functions used to represent Alpha
     // instructions.
index 38ba73d01f8fc82957ff8ec44e913e9ffde78ad9..bc6f02e4d653083d0352b4b85b42ccb8be617c5a 100644 (file)
@@ -191,10 +191,12 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
                     (*(CI->op_begin()+1))->getType(), MemsetFCache);
     break;
   }
-  case Intrinsic::isunordered: {
-    static Function *IsunorderedFCache = 0;
-    ReplaceCallWith("isunordered", CI, CI->op_begin()+1, CI->op_end(),
-                    (*(CI->op_begin()+1))->getType(), IsunorderedFCache);
+  case Intrinsic::isnan: {
+    // FIXME: This should force the argument to be a double.  There may be
+    // multiple isnans for different FP arguments.
+    static Function *isnanFCache = 0;
+    ReplaceCallWith("isnan", CI, CI->op_begin()+1, CI->op_end(),
+                    (*(CI->op_begin()+1))->getType(), isnanFCache);
     break;
   }
   }
index 82f3645acb10b534f7e581202faa445933b00353..a0f86d55e54d72e88b860f8c0c3932911e94ba7c 100644 (file)
@@ -223,7 +223,7 @@ unsigned Function::getIntrinsicID() const {
     if (getName() == "llvm.gcroot")  return Intrinsic::gcroot;
     break;
   case 'i':
-    if (getName() == "llvm.isunordered") return Intrinsic::isunordered;
+    if (getName() == "llvm.isnan") return Intrinsic::isnan;
     break;
   case 'l':
     if (getName() == "llvm.longjmp")  return Intrinsic::longjmp;
index 38ba73d01f8fc82957ff8ec44e913e9ffde78ad9..bc6f02e4d653083d0352b4b85b42ccb8be617c5a 100644 (file)
@@ -191,10 +191,12 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
                     (*(CI->op_begin()+1))->getType(), MemsetFCache);
     break;
   }
-  case Intrinsic::isunordered: {
-    static Function *IsunorderedFCache = 0;
-    ReplaceCallWith("isunordered", CI, CI->op_begin()+1, CI->op_end(),
-                    (*(CI->op_begin()+1))->getType(), IsunorderedFCache);
+  case Intrinsic::isnan: {
+    // FIXME: This should force the argument to be a double.  There may be
+    // multiple isnans for different FP arguments.
+    static Function *isnanFCache = 0;
+    ReplaceCallWith("isnan", CI, CI->op_begin()+1, CI->op_end(),
+                    (*(CI->op_begin()+1))->getType(), isnanFCache);
     break;
   }
   }
index 156b2cc45d15e025e974ba5965bb03b6123936e0..244d3464903c5a8748fc4f43b169531effd81bab 100644 (file)
@@ -688,7 +688,13 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
     break;
   }
 
-  case Intrinsic::isunordered:     NumArgs = 2; break;
+  case Intrinsic::isnan: 
+    Assert1(FT->getNumParams() == 1 && FT->getParamType(0)->isFloatingPoint(),
+            "Illegal prototype for llvm.isnan", IF);
+    Assert1(FT->getReturnType() == Type::BoolTy,
+            "Illegal prototype for llvm.isnan", IF);
+    NumArgs = 1;
+    break;
 
   case Intrinsic::setjmp:          NumArgs = 1; break;
   case Intrinsic::longjmp:         NumArgs = 2; break;