[llvm-commits] [llvm-gcc-4.0] r41259 - /llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
Bill Wendling
isanbard at gmail.com
Tue Aug 21 16:49:59 PDT 2007
Author: void
Date: Tue Aug 21 18:49:58 2007
New Revision: 41259
URL: http://llvm.org/viewvc/llvm-project?rev=41259&view=rev
Log:
For the llvm.c* intrinsics, we need to truncate or zero extend if we're placing
the results in a larger or smaller location.
Modified:
llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp?rev=41259&r1=41258&r2=41259&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Tue Aug 21 18:49:58 2007
@@ -4281,13 +4281,19 @@
case BUILT_IN_CLZLL: {
Value *Amt = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0);
EmitBuiltinUnaryIntOp(Amt, Result, Intrinsic::ctlz);
+ const Type *DestTy = ConvertType(TREE_TYPE(exp));
+ if (Result->getType() != DestTy)
+ Result = Builder.CreateIntCast(Result, DestTy, "cast");
return true;
}
case BUILT_IN_CTZ: // These GCC builtins always return int.
case BUILT_IN_CTZL:
case BUILT_IN_CTZLL: {
Value *Amt = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0);
- EmitBuiltinUnaryIntOp(Amt, Result, Intrinsic::cttz);
+ EmitBuiltinUnaryIntOp(Amt, Result, Intrinsic::cttz);
+ const Type *DestTy = ConvertType(TREE_TYPE(exp));
+ if (Result->getType() != DestTy)
+ Result = Builder.CreateIntCast(Result, DestTy, "cast");
return true;
}
case BUILT_IN_POPCOUNT: // These GCC builtins always return int.
@@ -4295,6 +4301,9 @@
case BUILT_IN_POPCOUNTLL: {
Value *Amt = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0);
EmitBuiltinUnaryIntOp(Amt, Result, Intrinsic::ctpop);
+ const Type *DestTy = ConvertType(TREE_TYPE(exp));
+ if (Result->getType() != DestTy)
+ Result = Builder.CreateIntCast(Result, DestTy, "cast");
return true;
}
case BUILT_IN_SQRT:
More information about the llvm-commits
mailing list