[llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c

Reid Spencer reid at x10sys.com
Mon Jan 16 14:21:26 PST 2006



Changes in directory llvm-gcc/gcc:

llvm-expand.c updated: 1.124 -> 1.125
---
Log message:

For PR411: http://llvm.cs.uiuc.edu/PR411 :
Cause llvm-gcc to emit the non-overloaded form of the intrinsics for
ctpop, cttz, ctlz, isunordered, and sqrt.


---
Diffs of the changes:  (+50 -7)

 llvm-expand.c |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 7 deletions(-)


Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.124 llvm-gcc/gcc/llvm-expand.c:1.125
--- llvm-gcc/gcc/llvm-expand.c:1.124	Mon Jan  9 13:42:32 2006
+++ llvm-gcc/gcc/llvm-expand.c	Mon Jan 16 16:21:14 2006
@@ -419,7 +419,7 @@
       FnTy->Elements[2] = FloatTy;
       FnTy = llvm_type_get_cannonical_function(FnTy);
       llvm_isunordered_float_fn =
-        G2V(CreateIntrinsicFnWithType("llvm.isunordered", FnTy));
+        G2V(CreateIntrinsicFnWithType("llvm.isunordered.f32", FnTy));
     }
 
     I->Operands[0] = llvm_isunordered_float_fn;
@@ -431,7 +431,7 @@
       FnTy->Elements[2] = DoubleTy;
       FnTy = llvm_type_get_cannonical_function(FnTy);
       llvm_isunordered_double_fn =
-        G2V(CreateIntrinsicFnWithType("llvm.isunordered", FnTy));
+        G2V(CreateIntrinsicFnWithType("llvm.isunordered.f64", FnTy));
     }
 
     I->Operands[0] = llvm_isunordered_double_fn;
@@ -4759,7 +4759,15 @@
   case BUILT_IN_SQRTL:
     /* If errno math has been disabled, expand these to llvm.sqrt calls. */
     if (!flag_errno_math) {
-      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.sqrt");
+      Op0 = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0);
+      switch (Op0->Ty->ID) {
+      case FloatTyID:
+        return llvm_expand_builtin_unaryop(Fn, DestTy, arglist,"llvm.sqrt.f32");
+      case DoubleTyID:
+        return llvm_expand_builtin_unaryop(Fn, DestTy, arglist,"llvm.sqrt.f64");
+      default:
+        abort(); /* shouldn't happen */
+      }
     } else {
       /* Otherwise, expand as a call to sqrt*.  */
       return llvm_expand_call (Fn, exp, DestLoc);
@@ -4941,16 +4949,51 @@
   case BUILT_IN_CLZ:
   case BUILT_IN_CLZL:
   case BUILT_IN_CLZLL:
-    return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.ctlz");
+    Op0 = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0);
+    switch (Op0->Ty->ID) {
+    case UByteTyID: case SByteTyID:          /* 8 bit types... */
+      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.ctlz.i8");
+    case UShortTyID: case ShortTyID:         /* 16 bit types... */
+      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.ctlz.i16");
+    case UIntTyID: case IntTyID:             /* 32 bit types... */
+      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.ctlz.i32");
+    case ULongTyID: case LongTyID:           /* 64 bit types... */
+      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.ctlz.i64");
+    default:
+      abort(); /* this shouldn't happen? */
+    }
   case BUILT_IN_CTZ:
   case BUILT_IN_CTZL:
   case BUILT_IN_CTZLL:
-    return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.cttz");
-
+    Op0 = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0);
+    switch (Op0->Ty->ID) {
+    case UByteTyID: case SByteTyID:          /* 8 bit types... */
+      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.cttz.i8");
+    case UShortTyID: case ShortTyID:         /* 16 bit types... */
+      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.cttz.i16");
+    case UIntTyID: case IntTyID:             /* 32 bit types... */
+      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.cttz.i32");
+    case ULongTyID: case LongTyID:           /* 64 bit types... */
+      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.cttz.i64");
+    default:
+      abort(); /* this shouldn't happen? */
+    }
   case BUILT_IN_POPCOUNT:
   case BUILT_IN_POPCOUNTL:
   case BUILT_IN_POPCOUNTLL:
-    return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.ctpop");
+    Op0 = llvm_expand_expr(Fn, TREE_VALUE(arglist), 0);
+    switch (Op0->Ty->ID) {
+    case UByteTyID: case SByteTyID:          /* 8 bit types... */
+      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.ctpop.i8");
+    case UShortTyID: case ShortTyID:         /* 16 bit types... */
+      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.ctpop.i16");
+    case UIntTyID: case IntTyID:             /* 32 bit types... */
+      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.ctpop.i32");
+    case ULongTyID: case LongTyID:           /* 64 bit types... */
+      return llvm_expand_builtin_unaryop(Fn, DestTy, arglist, "llvm.ctpop.i64");
+    default:
+      abort(); /* this shouldn't happen? */
+    }
 
 #if 0
   case BUILT_IN_PARITY:






More information about the llvm-commits mailing list