[llvm] r215173 - [AVX512] Add zero-masking variant to AVX512_masking multiclass

Adam Nemet anemet at apple.com
Thu Aug 7 16:53:38 PDT 2014


Author: anemet
Date: Thu Aug  7 18:53:38 2014
New Revision: 215173

URL: http://llvm.org/viewvc/llvm-project?rev=215173&view=rev
Log:
[AVX512] Add zero-masking variant to AVX512_masking multiclass

This completes one item from the todo-list of r215125 "Generate masking
instruction variants with tablegen".

The AddedComplexity is needed just like for the k variant.

Added a codegen test based on valignq.

Modified:
    llvm/trunk/lib/Target/X86/X86InstrAVX512.td
    llvm/trunk/test/CodeGen/X86/avx512-shuffle.ll

Modified: llvm/trunk/lib/Target/X86/X86InstrAVX512.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrAVX512.td?rev=215173&r1=215172&r2=215173&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrAVX512.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrAVX512.td Thu Aug  7 18:53:38 2014
@@ -1,7 +1,7 @@
 multiclass AVX512_masking<bits<8> O, Format F, dag Outs, dag Ins,
                               string OpcodeStr,
                               string AttSrcAsm, string IntelSrcAsm,
-                              dag RHS,
+                              dag RHS, ValueType OpVT,
                               RegisterClass RC, RegisterClass KRC> {
   def NAME: AVX512<O, F, Outs, Ins,
                        OpcodeStr#" \t{"#AttSrcAsm#", $dst|"#
@@ -17,6 +17,16 @@ multiclass AVX512_masking<bits<8> O, For
                        [(set RC:$dst,
                              (vselect KRC:$mask, RHS, RC:$src0))]>,
               EVEX_K;
+  let AddedComplexity = 30 in // Prefer over VMOV*rrkz Pat<>
+    def NAME#kz: AVX512<O, F, Outs,
+                       !con((ins KRC:$mask), Ins),
+                       OpcodeStr#" \t{"#AttSrcAsm#", $dst {${mask}} {z}|"#
+                                      "$dst {${mask}} {z}, "#IntelSrcAsm#"}",
+                       [(set RC:$dst,
+                             (vselect KRC:$mask, RHS,
+                                      (OpVT (bitconvert
+                                              (v16i32 immAllZerosV)))))]>,
+              EVEX_KZ;
 }
 
 // Bitcasts between 512-bit vector types. Return the original type since
@@ -4491,7 +4501,7 @@ multiclass avx512_valign<string Suffix,
                      "$src3, $src2, $src1", "$src1, $src2, $src3",
                      (IntVT (X86VAlign RC:$src2, RC:$src1,
                                        (i8 imm:$src3))),
-                     RC, KRC>,
+                     IntVT, RC, KRC>,
              AVX512AIi8Base, EVEX_4V;
 
   // Also match valign of packed floats.

Modified: llvm/trunk/test/CodeGen/X86/avx512-shuffle.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx512-shuffle.ll?rev=215173&r1=215172&r2=215173&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/avx512-shuffle.ll (original)
+++ llvm/trunk/test/CodeGen/X86/avx512-shuffle.ll Thu Aug  7 18:53:38 2014
@@ -216,6 +216,15 @@ define <8 x i64> @test16k(<8 x i64> %a,
   ret <8 x i64> %res
 }
 
+; CHECK-LABEL: test16kz
+; CHECK: valignq $2, %zmm0, %zmm1, %zmm0 {%k1} {z} ## encoding: [0x62,0xf3,0xf5,0xc9,0x03,0xc0,0x02]
+define <8 x i64> @test16kz(<8 x i64> %a, <8 x i64> %b, i8 %mask) nounwind {
+  %c = shufflevector <8 x i64> %a, <8 x i64> %b, <8 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9>
+  %m = bitcast i8 %mask to <8 x i1>
+  %res = select <8 x i1> %m, <8 x i64> %c, <8 x i64> zeroinitializer
+  ret <8 x i64> %res
+}
+
 ; CHECK-LABEL: test17
 ; CHECK: vshufpd $19, %zmm1, %zmm0
 ; CHECK: ret





More information about the llvm-commits mailing list