From ac106273d4ff77d259a63e82771aec29ca11ec1a Mon Sep 17 00:00:00 2001 From: Cameron Zwarich Date: Wed, 16 Mar 2011 22:20:18 +0000 Subject: The x86-64 ABI says that a bool is only guaranteed to be sign-extended to a byte rather than an int. Thankfully, this only causes LLVM to miss optimizations, not generate incorrect code. This just fixes the zext at the return. We still insert an i32 ZextAssert when reading a function's arguments, but it is followed by a truncate and another i8 ZextAssert so it is not optimized. llvm-svn: 127766 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 9 +++++++++ llvm/lib/Target/X86/X86ISelLowering.h | 3 +++ 2 files changed, 12 insertions(+) (limited to 'llvm/lib/Target') diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 910ed2abd1f..c1aa7200bef 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -1448,6 +1448,15 @@ bool X86TargetLowering::isUsedByReturnOnly(SDNode *N) const { return HasRet; } +MVT +X86TargetLowering::getTypeForExtendedInteger(EVT VT, + ISD::NodeType ExtendKind) const { + // TODO: Is this also valid on 32-bit? + if (Subtarget->is64Bit() && VT == MVT::i1 && ExtendKind == ISD::ZERO_EXTEND) + return MVT::i8; + return MVT::i32; +} + /// LowerCallResult - Lower the result values of a call into the /// appropriate copies out of appropriate physical registers. /// diff --git a/llvm/lib/Target/X86/X86ISelLowering.h b/llvm/lib/Target/X86/X86ISelLowering.h index 551884b18e4..0857c594b4f 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.h +++ b/llvm/lib/Target/X86/X86ISelLowering.h @@ -843,6 +843,9 @@ namespace llvm { virtual bool isUsedByReturnOnly(SDNode *N) const; + virtual MVT + getTypeForExtendedInteger(EVT VT, ISD::NodeType ExtendKind) const; + virtual bool CanLowerReturn(CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl &Outs, -- cgit v1.2.3