[llvm-commits] [dragonegg] r152550 - /dragonegg/trunk/src/x86/Target.cpp
Duncan Sands
baldrick at free.fr
Mon Mar 12 01:42:40 PDT 2012
Author: baldrick
Date: Mon Mar 12 03:42:40 2012
New Revision: 152550
URL: http://llvm.org/viewvc/llvm-project?rev=152550&view=rev
Log:
GCC extends the parameter to the 16 bit bit counting intrinsics from a 16 bit to
a 32 bit value before passing it to the intrinsic, probably due to C's implicit
extension of call arguments. Handle this by first chopping back down to 16 bits.
Modified:
dragonegg/trunk/src/x86/Target.cpp
Modified: dragonegg/trunk/src/x86/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/x86/Target.cpp?rev=152550&r1=152549&r2=152550&view=diff
==============================================================================
--- dragonegg/trunk/src/x86/Target.cpp (original)
+++ dragonegg/trunk/src/x86/Target.cpp Mon Mar 12 03:42:40 2012
@@ -900,15 +900,21 @@
return true;
}
case clzs: {
+ // The value is usually passed in as an int rather than as a short.
+ Type *Int16Ty = Builder.getInt16Ty();
+ Result = Builder.CreateTruncOrBitCast(Ops[0], Int16Ty);
Function *ctlz = Intrinsic::getDeclaration(TheModule, Intrinsic::ctlz,
- Ops[0]->getType());
- Result = Builder.CreateCall2(ctlz, Ops[0], Builder.getTrue());
+ Int16Ty);
+ Result = Builder.CreateCall2(ctlz, Result, Builder.getTrue());
return true;
}
case ctzs: {
+ // The value is usually passed in as an int rather than as a short.
+ Type *Int16Ty = Builder.getInt16Ty();
+ Result = Builder.CreateTruncOrBitCast(Ops[0], Int16Ty);
Function *cttz = Intrinsic::getDeclaration(TheModule, Intrinsic::cttz,
- Ops[0]->getType());
- Result = Builder.CreateCall2(cttz, Ops[0], Builder.getTrue());
+ Int16Ty);
+ Result = Builder.CreateCall2(cttz, Result, Builder.getTrue());
return true;
}
}
More information about the llvm-commits
mailing list