From e139a1e0e42045990990b0ef4f110c05fcfeae78 Mon Sep 17 00:00:00 2001 From: Elena Demikhovsky Date: Mon, 17 Feb 2014 07:29:33 +0000 Subject: [PATCH] AVX-512: implemented zext fron i1 to i16 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201502 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86InstrAVX512.td | 4 +++- test/CodeGen/X86/avx512-mask-op.ll | 36 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lib/Target/X86/X86InstrAVX512.td b/lib/Target/X86/X86InstrAVX512.td index 8da347bc077..bfd79c28133 100644 --- a/lib/Target/X86/X86InstrAVX512.td +++ b/lib/Target/X86/X86InstrAVX512.td @@ -969,7 +969,9 @@ let Predicates = [HasAVX512] in { def : Pat<(i64 (zext VK1:$src)), (SUBREG_TO_REG (i64 0), (KMOVWrk (COPY_TO_REGCLASS VK1:$src, VK16)), sub_32bit)>; - + def : Pat<(i16 (zext VK1:$src)), + (EXTRACT_SUBREG + (KMOVWrk (COPY_TO_REGCLASS VK1:$src, VK16)), sub_16bit)>; } // With AVX-512 only, 8-bit mask is promoted to 16-bit mask. let Predicates = [HasAVX512] in { diff --git a/test/CodeGen/X86/avx512-mask-op.ll b/test/CodeGen/X86/avx512-mask-op.ll index 923e72ec5f7..dd33ffdb640 100644 --- a/test/CodeGen/X86/avx512-mask-op.ll +++ b/test/CodeGen/X86/avx512-mask-op.ll @@ -42,3 +42,39 @@ define i8 @shuf_test1(i16 %v) nounwind { %mask1 = bitcast <8 x i1> %mask to i8 ret i8 %mask1 } + +; CHECK: zext_test1 +; CHECK: kshiftlw +; CHECK: kshiftrw +; CHECK: kmovw +; CHECK:ret +define i32 @zext_test1(<16 x i32> %a, <16 x i32> %b) { + %cmp_res = icmp ugt <16 x i32> %a, %b + %cmp_res.i1 = extractelement <16 x i1> %cmp_res, i32 5 + %res = zext i1 %cmp_res.i1 to i32 + ret i32 %res +} + +; CHECK: zext_test2 +; CHECK: kshiftlw +; CHECK: kshiftrw +; CHECK: kmovw +; CHECK:ret +define i16 @zext_test2(<16 x i32> %a, <16 x i32> %b) { + %cmp_res = icmp ugt <16 x i32> %a, %b + %cmp_res.i1 = extractelement <16 x i1> %cmp_res, i32 5 + %res = zext i1 %cmp_res.i1 to i16 + ret i16 %res +} + +; CHECK: zext_test3 +; CHECK: kshiftlw +; CHECK: kshiftrw +; CHECK: kmovw +; CHECK:ret +define i8 @zext_test3(<16 x i32> %a, <16 x i32> %b) { + %cmp_res = icmp ugt <16 x i32> %a, %b + %cmp_res.i1 = extractelement <16 x i1> %cmp_res, i32 5 + %res = zext i1 %cmp_res.i1 to i8 + ret i8 %res +}