Alpha doesn't have a native f32 extload instruction.
[oota-llvm.git] / lib / CodeGen / IntrinsicLowering.cpp
index 38ba73d01f8fc82957ff8ec44e913e9ffde78ad9..63ff815291381b682516a1df70af21de4e472a54 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/IntrinsicLowering.h"
+#include "llvm/CodeGen/IntrinsicLowering.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
-#include "llvm/iOther.h"
+#include "llvm/Instructions.h"
+#include <iostream>
+
 using namespace llvm;
 
 template <class ArgIt>
@@ -69,7 +71,14 @@ static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
 
   std::string Name = CI->getName(); CI->setName("");
   if (FT->getReturnType() == Type::VoidTy) Name.clear();
-  return new CallInst(FCache, Operands, Name, CI);
+  CallInst *NewCI = new CallInst(FCache, Operands, Name, CI);
+  if (!CI->use_empty()) {
+    Value *V = NewCI;
+    if (CI->getType() != NewCI->getType())
+      V = new CastInst(NewCI, CI->getType(), Name, CI);
+    CI->replaceAllUsesWith(V);
+  }
+  return NewCI;
 }
 
 void DefaultIntrinsicLowering::AddPrototypes(Module &M) {
@@ -98,7 +107,9 @@ void DefaultIntrinsicLowering::AddPrototypes(Module &M) {
         EnsureFunctionExists(M, "memset", I->abegin(), --I->aend(),
                              I->abegin()->getType());
         break;
-
+      case Intrinsic::isunordered:
+        EnsureFunctionExists(M, "isunordered", I->abegin(), I->aend(), Type::BoolTy);
+        break;
       }
 
 }
@@ -192,9 +203,9 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
     break;
   }
   case Intrinsic::isunordered: {
-    static Function *IsunorderedFCache = 0;
+    static Function *isunorderedFCache = 0;
     ReplaceCallWith("isunordered", CI, CI->op_begin()+1, CI->op_end(),
-                    (*(CI->op_begin()+1))->getType(), IsunorderedFCache);
+                    Type::BoolTy, isunorderedFCache);
     break;
   }
   }