[llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Apr 29 21:08:04 PDT 2005



Changes in directory llvm/lib/CodeGen:

IntrinsicLowering.cpp updated: 1.26 -> 1.27
---
Log message:

Lower llvm.sqrt -> fsqrt/sqrt


---
Diffs of the changes:  (+17 -1)

 IntrinsicLowering.cpp |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.26 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.27
--- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.26	Thu Apr 21 17:33:33 2005
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp	Fri Apr 29 23:07:50 2005
@@ -110,8 +110,13 @@
       case Intrinsic::isunordered:
         EnsureFunctionExists(M, "isunordered", I->arg_begin(), I->arg_end(), Type::BoolTy);
         break;
+      case Intrinsic::sqrt:
+        if(I->abegin()->getType() == Type::FloatTy)
+          EnsureFunctionExists(M, "sqrtf", I->arg_begin(), I->arg_end(), Type::FloatTy);
+        else
+          EnsureFunctionExists(M, "sqrt", I->arg_begin(), I->arg_end(), Type::DoubleTy);
+        break;
       }
-
 }
 
 void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
@@ -219,6 +224,17 @@
                              "isunordered", CI));
     break;
   }
+  case Intrinsic::sqrt: {
+    static Function *sqrtFCache = 0;
+    static Function *sqrtfFCache = 0;
+    if(CI->getType() == Type::FloatTy)
+      ReplaceCallWith("sqrtf", CI, CI->op_begin()+1, CI->op_end(),
+                      Type::FloatTy, sqrtfFCache);
+    else
+      ReplaceCallWith("sqrt", CI, CI->op_begin()+1, CI->op_end(),
+                      Type::DoubleTy, sqrtFCache);
+    break;
+  }
   }
 
   assert(CI->use_empty() &&






More information about the llvm-commits mailing list