[PATCH][AVX512] Add intrinsics for Packed Absolute Value

Cameron McInally cameron.mcinally at nyu.edu
Tue Dec 24 06:45:21 PST 2013


Hey guys,

Attached is a patch to support AVX512 Packed Absolute Value intrinsics.

Thanks,
Cameron
-------------- next part --------------
Index: test/CodeGen/X86/avx512-intrinsics.ll
===================================================================
--- test/CodeGen/X86/avx512-intrinsics.ll	(revision 197980)
+++ test/CodeGen/X86/avx512-intrinsics.ll	(working copy)
@@ -346,6 +346,20 @@
 }
 declare <8 x i64> @llvm.x86.avx512.pmins.q(<8 x i64>, <8 x i64>) nounwind readonly
 
+define <16 x i32> @test_x86_pabs_d(<16 x i32> %a0) {
+  ; CHECK: vpabsd
+  %res = call <16 x i32> @llvm.x86.avx512.pabs.d.512(<16 x i32> %a0) ; <<16 x i32>> [#uses=1]
+  ret <16 x i32> %res
+}
+declare <16 x i32> @llvm.x86.avx512.pabs.d.512(<16 x i32>) nounwind readnone
+
+define <8 x i64> @test_x86_pabs_q(<8 x i64> %a0) {
+  ; CHECK: vpabsq
+  %res = call <8 x i64> @llvm.x86.avx512.pabs.q.512(<8 x i64> %a0) ; <<8 x i64>> [#uses=1]
+  ret <8 x i64> %res
+}
+declare <8 x i64> @llvm.x86.avx512.pabs.q.512(<8 x i64>) nounwind readnone
+
 define <16 x i32> @test_conflict_d(<16 x i32> %a) {
   ; CHECK: movw $-1, %ax
   ; CHECK: vpxor
Index: include/llvm/IR/IntrinsicsX86.td
===================================================================
--- include/llvm/IR/IntrinsicsX86.td	(revision 197980)
+++ include/llvm/IR/IntrinsicsX86.td	(working copy)
@@ -2747,6 +2747,14 @@
          Intrinsic<[llvm_v8i64_ty], [llvm_i64_ty], [IntrNoMem]>;
 }
 
+// Absolute value ops
+let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
+  def int_x86_avx512_pabs_d_512 : GCCBuiltin<"__builtin_ia32_pabsd512">,
+              Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty], [IntrNoMem]>;
+  def int_x86_avx512_pabs_q_512 : GCCBuiltin<"__builtin_ia32_pabsq512">,
+              Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty], [IntrNoMem]>;
+}
+
 // Vector sign and zero extend
 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
   def int_x86_avx512_pmovzxbq : GCCBuiltin<"__builtin_ia32_pmovzxbq512">,
Index: lib/Target/X86/X86InstrAVX512.td
===================================================================
--- lib/Target/X86/X86InstrAVX512.td	(revision 197980)
+++ lib/Target/X86/X86InstrAVX512.td	(working copy)
@@ -3558,6 +3558,11 @@
 defm VPABSQ : avx512_vpabs<0x1F, "vpabsq", VR512, i512mem>, EVEX_V512, VEX_W,
                         EVEX_CD8<64, CD8VF>;
 
+def : Pat<(int_x86_avx512_pabs_d_512 VR512:$src),
+          (VPABSDrr VR512:$src)>;
+def : Pat<(int_x86_avx512_pabs_q_512 VR512:$src),
+          (VPABSQrr VR512:$src)>;
+
 multiclass avx512_conflict<bits<8> opc, string OpcodeStr, 
                         RegisterClass RC, RegisterClass KRC,
                         X86MemOperand x86memop,


More information about the llvm-commits mailing list