diff options
author | Elena Demikhovsky <elena.demikhovsky@intel.com> | 2015-04-27 15:11:19 +0000 |
---|---|---|
committer | Elena Demikhovsky <elena.demikhovsky@intel.com> | 2015-04-27 15:11:19 +0000 |
commit | f8ae1af2e16b13641e0bfe279e1b8232ae5f1d62 (patch) | |
tree | 2722b2f2589fef0b933356fc35da5a1cf096d0cc | |
parent | 2afd045e031f104b3feb0b8fb8aa8733ccc8256b (diff) |
AVX-512: added calling conventions for i1 vectors.
Fixed bug: https://llvm.org/bugs/show_bug.cgi?id=20724
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235889 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/X86CallingConv.td | 20 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 10 | ||||
-rw-r--r-- | test/CodeGen/X86/avx512-calling-conv.ll | 44 |
3 files changed, 71 insertions, 3 deletions
diff --git a/lib/Target/X86/X86CallingConv.td b/lib/Target/X86/X86CallingConv.td index 41c759a52ee..8ce911079f4 100644 --- a/lib/Target/X86/X86CallingConv.td +++ b/lib/Target/X86/X86CallingConv.td @@ -39,6 +39,16 @@ def RetCC_X86Common : CallingConv<[ CCIfType<[i32], CCAssignToReg<[EAX, EDX, ECX]>>, CCIfType<[i64], CCAssignToReg<[RAX, RDX, RCX]>>, + // Boolean vectors of AVX-512 are returned in SIMD registers. + // The call from AVX to AVX-512 function should work, + // since the boolean types in AVX/AVX2 are promoted by default. + CCIfType<[v2i1], CCPromoteToType<v2i64>>, + CCIfType<[v4i1], CCPromoteToType<v4i32>>, + CCIfType<[v8i1], CCPromoteToType<v8i16>>, + CCIfType<[v16i1], CCPromoteToType<v16i8>>, + CCIfType<[v32i1], CCPromoteToType<v32i8>>, + CCIfType<[v64i1], CCPromoteToType<v64i8>>, + // Vector types are returned in XMM0 and XMM1, when they fit. XMM2 and XMM3 // can only be used by ABI non-compliant code. If the target doesn't have XMM // registers, it won't have vector types. @@ -258,6 +268,16 @@ def CC_X86_64_C : CallingConv<[ CCIfSubtarget<"hasSSE2()", CCPromoteToType<v2i64>>>>, + // Boolean vectors of AVX-512 are returned in SIMD registers. + // The call from AVX to AVX-512 function should work, + // since the boolean types in AVX/AVX2 are promoted by default. + CCIfType<[v2i1], CCPromoteToType<v2i64>>, + CCIfType<[v4i1], CCPromoteToType<v4i32>>, + CCIfType<[v8i1], CCPromoteToType<v8i16>>, + CCIfType<[v16i1], CCPromoteToType<v16i8>>, + CCIfType<[v32i1], CCPromoteToType<v32i8>>, + CCIfType<[v64i1], CCPromoteToType<v64i8>>, + // The first 8 FP/Vector arguments are passed in XMM registers. CCIfType<[f32, f64, v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], CCIfSubtarget<"hasSSE1()", diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index bf61ab8ba4b..079880ef4a1 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -1907,8 +1907,12 @@ X86TargetLowering::LowerReturn(SDValue Chain, ValToCopy = DAG.getNode(ISD::SIGN_EXTEND, dl, VA.getLocVT(), ValToCopy); else if (VA.getLocInfo() == CCValAssign::ZExt) ValToCopy = DAG.getNode(ISD::ZERO_EXTEND, dl, VA.getLocVT(), ValToCopy); - else if (VA.getLocInfo() == CCValAssign::AExt) - ValToCopy = DAG.getNode(ISD::ANY_EXTEND, dl, VA.getLocVT(), ValToCopy); + else if (VA.getLocInfo() == CCValAssign::AExt) { + if (ValVT.getScalarType() == MVT::i1) + ValToCopy = DAG.getNode(ISD::SIGN_EXTEND, dl, VA.getLocVT(), ValToCopy); + else + ValToCopy = DAG.getNode(ISD::ANY_EXTEND, dl, VA.getLocVT(), ValToCopy); + } else if (VA.getLocInfo() == CCValAssign::BCvt) ValToCopy = DAG.getNode(ISD::BITCAST, dl, VA.getLocVT(), ValToCopy); @@ -2376,7 +2380,7 @@ X86TargetLowering::LowerFormalArguments(SDValue Chain, if (VA.isExtInLoc()) { // Handle MMX values passed in XMM regs. - if (RegVT.isVector()) + if (RegVT.isVector() && VA.getValVT().getScalarType() != MVT::i1) ArgValue = DAG.getNode(X86ISD::MOVDQ2Q, dl, VA.getValVT(), ArgValue); else ArgValue = DAG.getNode(ISD::TRUNCATE, dl, VA.getValVT(), ArgValue); diff --git a/test/CodeGen/X86/avx512-calling-conv.ll b/test/CodeGen/X86/avx512-calling-conv.ll new file mode 100644 index 00000000000..cd09218810e --- /dev/null +++ b/test/CodeGen/X86/avx512-calling-conv.ll @@ -0,0 +1,44 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=knl | FileCheck %s --check-prefix=KNL +; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=skx | FileCheck %s --check-prefix=SKX + +; KNL-LABEL: test1 +; KNL: vxorps +define <16 x i1> @test1() { + ret <16 x i1> zeroinitializer +} + +; SKX-LABEL: test2 +; SKX: vpmovb2m +; SKX: vpmovb2m +; SKX: kandw +; SKX: vpmovm2b +; KNL-LABEL: test2 +; KNL: vpmovsxbd +; KNL: vpmovsxbd +; KNL: vpandd +; KNL: vpmovdb +define <16 x i1> @test2(<16 x i1>%a, <16 x i1>%b) { + %c = and <16 x i1>%a, %b + ret <16 x i1> %c +} + +; SKX-LABEL: test3 +; SKX: vpmovw2m +; SKX: vpmovw2m +; SKX: kandb +; SKX: vpmovm2w +define <8 x i1> @test3(<8 x i1>%a, <8 x i1>%b) { + %c = and <8 x i1>%a, %b + ret <8 x i1> %c +} + +; SKX-LABEL: test4 +; SKX: vpmovd2m +; SKX: vpmovd2m +; SKX: kandw +; SKX: vpmovm2d +define <4 x i1> @test4(<4 x i1>%a, <4 x i1>%b) { + %c = and <4 x i1>%a, %b + ret <4 x i1> %c +} + |