From: Michael Zuckerman Date: Tue, 31 Oct 2017 10:00:19 +0000 (+0000) Subject: [AVX512] Adding new patterns for extract_subvector of vXi1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e58831cb868c59036fcd4d935ef6f08627c4888;p=platform%2Fupstream%2Fllvm.git [AVX512] Adding new patterns for extract_subvector of vXi1 extract subvector of vXi1 from vYi1 is poorly supported by LLVM and most of the time end with an assertion. This patch fixes this issue by adding new patterns to the TD file. Reviewers: 1. guyblank 2. igorb 3. zvi 4. ayman 5. craig.topper Differential Revision: https://reviews.llvm.org/D39292 Change-Id: Ideb4d7e946c8d40cfce2920891f2d89fe64c58f8 llvm-svn: 316981 --- diff --git a/llvm/lib/Target/X86/X86InstrAVX512.td b/llvm/lib/Target/X86/X86InstrAVX512.td index 4002b1f..41d7b3b 100644 --- a/llvm/lib/Target/X86/X86InstrAVX512.td +++ b/llvm/lib/Target/X86/X86InstrAVX512.td @@ -192,6 +192,7 @@ class X86KVectorVTInfo; def v2i1_info : X86KVectorVTInfo; def v4i1_info : X86KVectorVTInfo; def v8i1_info : X86KVectorVTInfo; @@ -2935,21 +2936,48 @@ defm : operation_subvector_mask_lowering; defm : operation_subvector_mask_lowering; -def : Pat<(v2i1 (extract_subvector (v4i1 VK4:$src), (iPTR 2))), - (v2i1 (COPY_TO_REGCLASS - (KSHIFTRWri (COPY_TO_REGCLASS VK4:$src, VK16), (i8 2)), - VK2))>; -def : Pat<(v4i1 (extract_subvector (v8i1 VK8:$src), (iPTR 4))), - (v4i1 (COPY_TO_REGCLASS - (KSHIFTRWri (COPY_TO_REGCLASS VK8:$src, VK16), (i8 4)), - VK4))>; -def : Pat<(v8i1 (extract_subvector (v16i1 VK16:$src), (iPTR 8))), - (v8i1 (COPY_TO_REGCLASS (KSHIFTRWri VK16:$src, (i8 8)), VK8))>; -def : Pat<(v16i1 (extract_subvector (v32i1 VK32:$src), (iPTR 16))), - (v16i1 (COPY_TO_REGCLASS (KSHIFTRDri VK32:$src, (i8 16)), VK16))>; -def : Pat<(v32i1 (extract_subvector (v64i1 VK64:$src), (iPTR 32))), - (v32i1 (COPY_TO_REGCLASS (KSHIFTRQri VK64:$src, (i8 32)), VK32))>; +multiclass vextract_for_mask_to_mask { +let Predicates = [prd] in + def : + Pat<(To.KVT(extract_subvector(From.KVT From.KRC:$src), (iPTR imm:$imm8))), + (To.KVT(COPY_TO_REGCLASS + (!cast(InstrStr#"ri") From.KVT:$src, + (i8 imm:$imm8)), To.KRC))>; +} + +multiclass vextract_for_mask_to_mask_legal_w { +def : + Pat<(To.KVT(extract_subvector(From.KVT From.KRC:$src), (iPTR imm:$imm8))), + (To.KVT(COPY_TO_REGCLASS + (KSHIFTRWri(COPY_TO_REGCLASS From.KRC:$src, VK16), + (i8 imm:$imm8)), To.KRC))>; +} + +defm : vextract_for_mask_to_mask_legal_w; +defm : vextract_for_mask_to_mask_legal_w; +defm : vextract_for_mask_to_mask_legal_w; +defm : vextract_for_mask_to_mask_legal_w; +defm : vextract_for_mask_to_mask_legal_w; +defm : vextract_for_mask_to_mask_legal_w; + +defm : vextract_for_mask_to_mask<"KSHIFTRW", v16i1_info, v1i1_info, HasAVX512>; +defm : vextract_for_mask_to_mask<"KSHIFTRD", v32i1_info, v1i1_info, HasBWI>; +defm : vextract_for_mask_to_mask<"KSHIFTRQ", v64i1_info, v1i1_info, HasBWI>; +defm : vextract_for_mask_to_mask<"KSHIFTRW", v16i1_info, v2i1_info, HasAVX512>; +defm : vextract_for_mask_to_mask<"KSHIFTRD", v32i1_info, v2i1_info, HasBWI>; +defm : vextract_for_mask_to_mask<"KSHIFTRQ", v64i1_info, v2i1_info, HasBWI>; +defm : vextract_for_mask_to_mask<"KSHIFTRW", v16i1_info, v4i1_info, HasAVX512>; +defm : vextract_for_mask_to_mask<"KSHIFTRD", v32i1_info, v4i1_info, HasBWI>; +defm : vextract_for_mask_to_mask<"KSHIFTRQ", v64i1_info, v4i1_info, HasBWI>; +defm : vextract_for_mask_to_mask<"KSHIFTRW", v16i1_info, v8i1_info, HasAVX512>; +defm : vextract_for_mask_to_mask<"KSHIFTRD", v32i1_info, v8i1_info, HasBWI>; +defm : vextract_for_mask_to_mask<"KSHIFTRQ", v64i1_info, v8i1_info, HasBWI>; +defm : vextract_for_mask_to_mask<"KSHIFTRD", v32i1_info, v16i1_info, HasBWI>; +defm : vextract_for_mask_to_mask<"KSHIFTRQ", v64i1_info, v16i1_info, HasBWI>; +defm : vextract_for_mask_to_mask<"KSHIFTRQ", v64i1_info, v32i1_info, HasBWI>; // Patterns for kmask shift multiclass mask_shift_lowering {