[llvm-commits] [llvm-gcc-4.2] r41260 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Bill Wendling
isanbard at gmail.com
Tue Aug 21 16:53:01 PDT 2007
Author: void
Date: Tue Aug 21 18:53:01 2007
New Revision: 41260
URL: http://llvm.org/viewvc/llvm-project?rev=41260&view=rev
Log:
Forward-port of 41259:
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.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=41260&r1=41259&r2=41260&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Aug 21 18:53:01 2007
@@ -3849,13 +3849,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_PARITYLL:
@@ -3872,6 +3878,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