diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -3946,16 +3946,7 @@ ArgValue = DAG.getCopyFromReg(Chain, dl, Reg, RegVT); } - // If this is an 8 or 16-bit value, it is really passed promoted to 32 - // bits. Insert an assert[sz]ext to capture this, then truncate to the - // right size. - if (VA.getLocInfo() == CCValAssign::SExt) - ArgValue = DAG.getNode(ISD::AssertSext, dl, RegVT, ArgValue, - DAG.getValueType(VA.getValVT())); - else if (VA.getLocInfo() == CCValAssign::ZExt) - ArgValue = DAG.getNode(ISD::AssertZext, dl, RegVT, ArgValue, - DAG.getValueType(VA.getValVT())); - else if (VA.getLocInfo() == CCValAssign::BCvt) + if (VA.getLocInfo() == CCValAssign::BCvt) ArgValue = DAG.getBitcast(VA.getValVT(), ArgValue); if (VA.isExtInLoc()) { diff --git a/llvm/test/CodeGen/X86/callee-extend.ll b/llvm/test/CodeGen/X86/callee-extend.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/X86/callee-extend.ll @@ -0,0 +1,48 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; Ignore the zeroext/signext attribute and always do sign/zero extension in the callee. +; RUN: llc < %s -mtriple=x86_64-unknown-linux | FileCheck %s + +define i64 @calleeu8(i8 noundef zeroext %a) nounwind { +; CHECK-LABEL: calleeu8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: # kill: def $edi killed $edi def $rdi +; CHECK-NEXT: movzbl %dil, %eax +; CHECK-NEXT: retq +entry: + %conv = zext i8 %a to i64 + ret i64 %conv +} + +define i64 @calleeu16(i16 noundef zeroext %a) nounwind { +; CHECK-LABEL: calleeu16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: # kill: def $edi killed $edi def $rdi +; CHECK-NEXT: movzwl %di, %eax +; CHECK-NEXT: retq +entry: + %conv = zext i16 %a to i64 + ret i64 %conv +} + +define i64 @callees8(i8 noundef signext %a) nounwind { +; CHECK-LABEL: callees8: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: # kill: def $edi killed $edi def $rdi +; CHECK-NEXT: movsbq %dil, %rax +; CHECK-NEXT: retq +entry: + %conv = sext i8 %a to i64 + ret i64 %conv +} + +define i64 @callees16(i16 noundef signext %a) nounwind { +; CHECK-LABEL: callees16: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: # kill: def $edi killed $edi def $rdi +; CHECK-NEXT: movswq %di, %rax +; CHECK-NEXT: retq +entry: + %conv = sext i16 %a to i64 + ret i64 %conv +} +