From b84cc10c3cfd0afb8d518811d689f8887beb77e8 Mon Sep 17 00:00:00 2001 From: Elena Demikhovsky Date: Tue, 22 Apr 2014 14:13:10 +0000 Subject: [PATCH] AVX-512: store and truncstore for i1 values git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206897 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelLowering.cpp | 1 + lib/Target/X86/X86InstrAVX512.td | 12 ++++++++++++ test/CodeGen/X86/avx512-mov.ll | 25 ++++++++++++++++++++++--- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 15f4f06a12d..b59861f033e 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -14393,6 +14393,7 @@ const char *X86TargetLowering::getTargetNodeName(unsigned Opcode) const { case X86ISD::UNPCKH: return "X86ISD::UNPCKH"; case X86ISD::VBROADCAST: return "X86ISD::VBROADCAST"; case X86ISD::VBROADCASTM: return "X86ISD::VBROADCASTM"; + case X86ISD::VEXTRACT: return "X86ISD::VEXTRACT"; case X86ISD::VPERMILP: return "X86ISD::VPERMILP"; case X86ISD::VPERM2X128: return "X86ISD::VPERM2X128"; case X86ISD::VPERMV: return "X86ISD::VPERMV"; diff --git a/lib/Target/X86/X86InstrAVX512.td b/lib/Target/X86/X86InstrAVX512.td index 6d61a4cab75..d7f05bc9e34 100644 --- a/lib/Target/X86/X86InstrAVX512.td +++ b/lib/Target/X86/X86InstrAVX512.td @@ -4265,3 +4265,15 @@ def : Pat<(int_x86_avx512_mask_conflict_q_512 VR512:$src2, VR512:$src1, def : Pat<(store (i1 -1), addr:$dst), (MOV8mi addr:$dst, (i8 1))>; def : Pat<(store (i1 1), addr:$dst), (MOV8mi addr:$dst, (i8 1))>; def : Pat<(store (i1 0), addr:$dst), (MOV8mi addr:$dst, (i8 0))>; + +def : Pat<(store VK1:$src, addr:$dst), + (KMOVWmk addr:$dst, (COPY_TO_REGCLASS VK1:$src, VK16))>; + +def truncstorei1 : PatFrag<(ops node:$val, node:$ptr), + (truncstore node:$val, node:$ptr), [{ + return cast(N)->getMemoryVT() == MVT::i1; +}]>; + +def : Pat<(truncstorei1 GR8:$src, addr:$dst), + (MOV8mr addr:$dst, GR8:$src)>; + diff --git a/test/CodeGen/X86/avx512-mov.ll b/test/CodeGen/X86/avx512-mov.ll index a769eb61d92..009802f1742 100644 --- a/test/CodeGen/X86/avx512-mov.ll +++ b/test/CodeGen/X86/avx512-mov.ll @@ -153,12 +153,31 @@ define void @test18(i8 * %addr, <8 x i64> %data) { ret void } -; CHECK-LABEL: store_i1 +; CHECK-LABEL: store_i1_1 ; CHECK: movb ; CHECK: movb ; CHECK: ret -define void @store_i1() { +define void @store_i1_1() { store i1 true, i1 addrspace(3)* undef, align 128 store i1 false, i1 addrspace(2)* undef, align 128 ret void -} \ No newline at end of file +} + +; CHECK-LABEL: store_i1_2 +; CHECK: movb +; CHECK: ret +define void @store_i1_2(i64 %a, i64 %b) { + %res = icmp eq i64 %a, %b + store i1 %res, i1 addrspace(3)* undef, align 128 + ret void +} + +; CHECK-LABEL: store_i1_3 +; CHECK: kmovw +; CHECK: ret +define void @store_i1_3(i16 %a) { + %a_vec = bitcast i16 %a to <16 x i1> + %res = extractelement <16 x i1> %a_vec, i32 4 + store i1 %res, i1 addrspace(3)* undef, align 128 + ret void +}