From d04cd2fbfe1779bb005c75b99c404f50645e3b6f Mon Sep 17 00:00:00 2001 From: Robert Khasanov Date: Tue, 16 Dec 2014 18:24:07 +0000 Subject: [PATCH] [AVX512] Enable integer arithmetic lowering for AVX512BW/VL subsets. Added lowering tests. llvm-svn: 224349 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 5 + llvm/lib/Target/X86/X86InstrSSE.td | 2 +- llvm/test/CodeGen/X86/avx512bw-arith.ll | 102 +++++++++++ llvm/test/CodeGen/X86/avx512bwvl-arith.ll | 206 +++++++++++++++++++++ llvm/test/CodeGen/X86/avx512vl-arith.ll | 291 ++++++++++++++++++++++++++++++ 5 files changed, 605 insertions(+), 1 deletion(-) create mode 100644 llvm/test/CodeGen/X86/avx512bw-arith.ll create mode 100644 llvm/test/CodeGen/X86/avx512bwvl-arith.ll create mode 100644 llvm/test/CodeGen/X86/avx512vl-arith.ll diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index e029b4b..2cd1d12 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -1546,6 +1546,11 @@ void X86TargetLowering::resetOperationActions() { setOperationAction(ISD::LOAD, MVT::v64i8, Legal); setOperationAction(ISD::SETCC, MVT::v32i1, Custom); setOperationAction(ISD::SETCC, MVT::v64i1, Custom); + setOperationAction(ISD::ADD, MVT::v32i16, Legal); + setOperationAction(ISD::ADD, MVT::v64i8, Legal); + setOperationAction(ISD::SUB, MVT::v32i16, Legal); + setOperationAction(ISD::SUB, MVT::v64i8, Legal); + setOperationAction(ISD::MUL, MVT::v32i16, Legal); for (int i = MVT::v32i8; i != MVT::v8i64; ++i) { const MVT VT = (MVT::SimpleValueType)i; diff --git a/llvm/lib/Target/X86/X86InstrSSE.td b/llvm/lib/Target/X86/X86InstrSSE.td index 9aa6fa0..0474bb9 100644 --- a/llvm/lib/Target/X86/X86InstrSSE.td +++ b/llvm/lib/Target/X86/X86InstrSSE.td @@ -7187,7 +7187,7 @@ let Constraints = "$src1 = $dst" in { SSE_INTMUL_ITINS_P, 1>; } -let Predicates = [HasAVX] in { +let Predicates = [HasAVX, NoVLX] in { defm VPMULLD : SS48I_binop_rm<0x40, "vpmulld", mul, v4i32, VR128, memopv2i64, i128mem, 0, SSE_PMULLD_ITINS>, VEX_4V; diff --git a/llvm/test/CodeGen/X86/avx512bw-arith.ll b/llvm/test/CodeGen/X86/avx512bw-arith.ll new file mode 100644 index 0000000..94f68a2 --- /dev/null +++ b/llvm/test/CodeGen/X86/avx512bw-arith.ll @@ -0,0 +1,102 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=knl -mattr=+avx512bw| FileCheck %s + +; CHECK-LABEL: vpaddb512_test +; CHECK: vpaddb %zmm{{.*}} +; CHECK: ret +define <64 x i8> @vpaddb512_test(<64 x i8> %i, <64 x i8> %j) nounwind readnone { + %x = add <64 x i8> %i, %j + ret <64 x i8> %x +} + +; CHECK-LABEL: vpaddb512_fold_test +; CHECK: vpaddb (%rdi), %zmm{{.*}} +; CHECK: ret +define <64 x i8> @vpaddb512_fold_test(<64 x i8> %i, <64 x i8>* %j) nounwind { + %tmp = load <64 x i8>* %j, align 4 + %x = add <64 x i8> %i, %tmp + ret <64 x i8> %x +} + +; CHECK-LABEL: vpaddw512_test +; CHECK: vpaddw %zmm{{.*}} +; CHECK: ret +define <32 x i16> @vpaddw512_test(<32 x i16> %i, <32 x i16> %j) nounwind readnone { + %x = add <32 x i16> %i, %j + ret <32 x i16> %x +} + +; CHECK-LABEL: vpaddw512_fold_test +; CHECK: vpaddw (%rdi), %zmm{{.*}} +; CHECK: ret +define <32 x i16> @vpaddw512_fold_test(<32 x i16> %i, <32 x i16>* %j) nounwind { + %tmp = load <32 x i16>* %j, align 4 + %x = add <32 x i16> %i, %tmp + ret <32 x i16> %x +} + +; CHECK-LABEL: vpaddw512_mask_test +; CHECK: vpaddw %zmm{{.*%k[1-7].*}} +; CHECK: ret +define <32 x i16> @vpaddw512_mask_test(<32 x i16> %i, <32 x i16> %j, <32 x i16> %mask1) nounwind readnone { + %mask = icmp ne <32 x i16> %mask1, zeroinitializer + %x = add <32 x i16> %i, %j + %r = select <32 x i1> %mask, <32 x i16> %x, <32 x i16> %i + ret <32 x i16> %r +} + +; CHECK-LABEL: vpaddw512_maskz_test +; CHECK: vpaddw %zmm{{.*{%k[1-7]} {z}.*}} +; CHECK: ret +define <32 x i16> @vpaddw512_maskz_test(<32 x i16> %i, <32 x i16> %j, <32 x i16> %mask1) nounwind readnone { + %mask = icmp ne <32 x i16> %mask1, zeroinitializer + %x = add <32 x i16> %i, %j + %r = select <32 x i1> %mask, <32 x i16> %x, <32 x i16> zeroinitializer + ret <32 x i16> %r +} + +; CHECK-LABEL: vpaddw512_mask_fold_test +; CHECK: vpaddw (%rdi), %zmm{{.*%k[1-7]}} +; CHECK: ret +define <32 x i16> @vpaddw512_mask_fold_test(<32 x i16> %i, <32 x i16>* %j.ptr, <32 x i16> %mask1) nounwind readnone { + %mask = icmp ne <32 x i16> %mask1, zeroinitializer + %j = load <32 x i16>* %j.ptr + %x = add <32 x i16> %i, %j + %r = select <32 x i1> %mask, <32 x i16> %x, <32 x i16> %i + ret <32 x i16> %r +} + +; CHECK-LABEL: vpaddw512_maskz_fold_test +; CHECK: vpaddw (%rdi), %zmm{{.*{%k[1-7]} {z}}} +; CHECK: ret +define <32 x i16> @vpaddw512_maskz_fold_test(<32 x i16> %i, <32 x i16>* %j.ptr, <32 x i16> %mask1) nounwind readnone { + %mask = icmp ne <32 x i16> %mask1, zeroinitializer + %j = load <32 x i16>* %j.ptr + %x = add <32 x i16> %i, %j + %r = select <32 x i1> %mask, <32 x i16> %x, <32 x i16> zeroinitializer + ret <32 x i16> %r +} + +; CHECK-LABEL: vpsubb512_test +; CHECK: vpsubb %zmm{{.*}} +; CHECK: ret +define <64 x i8> @vpsubb512_test(<64 x i8> %i, <64 x i8> %j) nounwind readnone { + %x = sub <64 x i8> %i, %j + ret <64 x i8> %x +} + +; CHECK-LABEL: vpsubw512_test +; CHECK: vpsubw %zmm{{.*}} +; CHECK: ret +define <32 x i16> @vpsubw512_test(<32 x i16> %i, <32 x i16> %j) nounwind readnone { + %x = sub <32 x i16> %i, %j + ret <32 x i16> %x +} + +; CHECK-LABEL: vpmullw512_test +; CHECK: vpmullw %zmm{{.*}} +; CHECK: ret +define <32 x i16> @vpmullw512_test(<32 x i16> %i, <32 x i16> %j) { + %x = mul <32 x i16> %i, %j + ret <32 x i16> %x +} + diff --git a/llvm/test/CodeGen/X86/avx512bwvl-arith.ll b/llvm/test/CodeGen/X86/avx512bwvl-arith.ll new file mode 100644 index 0000000..96f0140 --- /dev/null +++ b/llvm/test/CodeGen/X86/avx512bwvl-arith.ll @@ -0,0 +1,206 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=knl -mattr=+avx512bw -mattr=+avx512vl| FileCheck %s + +; 256-bit + +; CHECK-LABEL: vpaddb256_test +; CHECK: vpaddb %ymm{{.*}} +; CHECK: ret +define <32 x i8> @vpaddb256_test(<32 x i8> %i, <32 x i8> %j) nounwind readnone { + %x = add <32 x i8> %i, %j + ret <32 x i8> %x +} + +; CHECK-LABEL: vpaddb256_fold_test +; CHECK: vpaddb (%rdi), %ymm{{.*}} +; CHECK: ret +define <32 x i8> @vpaddb256_fold_test(<32 x i8> %i, <32 x i8>* %j) nounwind { + %tmp = load <32 x i8>* %j, align 4 + %x = add <32 x i8> %i, %tmp + ret <32 x i8> %x +} + +; CHECK-LABEL: vpaddw256_test +; CHECK: vpaddw %ymm{{.*}} +; CHECK: ret +define <16 x i16> @vpaddw256_test(<16 x i16> %i, <16 x i16> %j) nounwind readnone { + %x = add <16 x i16> %i, %j + ret <16 x i16> %x +} + +; CHECK-LABEL: vpaddw256_fold_test +; CHECK: vpaddw (%rdi), %ymm{{.*}} +; CHECK: ret +define <16 x i16> @vpaddw256_fold_test(<16 x i16> %i, <16 x i16>* %j) nounwind { + %tmp = load <16 x i16>* %j, align 4 + %x = add <16 x i16> %i, %tmp + ret <16 x i16> %x +} + +; CHECK-LABEL: vpaddw256_mask_test +; CHECK: vpaddw %ymm{{.*%k[1-7].*}} +; CHECK: ret +define <16 x i16> @vpaddw256_mask_test(<16 x i16> %i, <16 x i16> %j, <16 x i16> %mask1) nounwind readnone { + %mask = icmp ne <16 x i16> %mask1, zeroinitializer + %x = add <16 x i16> %i, %j + %r = select <16 x i1> %mask, <16 x i16> %x, <16 x i16> %i + ret <16 x i16> %r +} + +; CHECK-LABEL: vpaddw256_maskz_test +; CHECK: vpaddw %ymm{{.*{%k[1-7]} {z}.*}} +; CHECK: ret +define <16 x i16> @vpaddw256_maskz_test(<16 x i16> %i, <16 x i16> %j, <16 x i16> %mask1) nounwind readnone { + %mask = icmp ne <16 x i16> %mask1, zeroinitializer + %x = add <16 x i16> %i, %j + %r = select <16 x i1> %mask, <16 x i16> %x, <16 x i16> zeroinitializer + ret <16 x i16> %r +} + +; CHECK-LABEL: vpaddw256_mask_fold_test +; CHECK: vpaddw (%rdi), %ymm{{.*%k[1-7]}} +; CHECK: ret +define <16 x i16> @vpaddw256_mask_fold_test(<16 x i16> %i, <16 x i16>* %j.ptr, <16 x i16> %mask1) nounwind readnone { + %mask = icmp ne <16 x i16> %mask1, zeroinitializer + %j = load <16 x i16>* %j.ptr + %x = add <16 x i16> %i, %j + %r = select <16 x i1> %mask, <16 x i16> %x, <16 x i16> %i + ret <16 x i16> %r +} + +; CHECK-LABEL: vpaddw256_maskz_fold_test +; CHECK: vpaddw (%rdi), %ymm{{.*{%k[1-7]} {z}}} +; CHECK: ret +define <16 x i16> @vpaddw256_maskz_fold_test(<16 x i16> %i, <16 x i16>* %j.ptr, <16 x i16> %mask1) nounwind readnone { + %mask = icmp ne <16 x i16> %mask1, zeroinitializer + %j = load <16 x i16>* %j.ptr + %x = add <16 x i16> %i, %j + %r = select <16 x i1> %mask, <16 x i16> %x, <16 x i16> zeroinitializer + ret <16 x i16> %r +} + +; CHECK-LABEL: vpsubb256_test +; CHECK: vpsubb %ymm{{.*}} +; CHECK: ret +define <32 x i8> @vpsubb256_test(<32 x i8> %i, <32 x i8> %j) nounwind readnone { + %x = sub <32 x i8> %i, %j + ret <32 x i8> %x +} + +; CHECK-LABEL: vpsubw256_test +; CHECK: vpsubw %ymm{{.*}} +; CHECK: ret +define <16 x i16> @vpsubw256_test(<16 x i16> %i, <16 x i16> %j) nounwind readnone { + %x = sub <16 x i16> %i, %j + ret <16 x i16> %x +} + +; CHECK-LABEL: vpmullw256_test +; CHECK: vpmullw %ymm{{.*}} +; CHECK: ret +define <16 x i16> @vpmullw256_test(<16 x i16> %i, <16 x i16> %j) { + %x = mul <16 x i16> %i, %j + ret <16 x i16> %x +} + +; 128-bit + +; CHECK-LABEL: vpaddb128_test +; CHECK: vpaddb %xmm{{.*}} +; CHECK: ret +define <16 x i8> @vpaddb128_test(<16 x i8> %i, <16 x i8> %j) nounwind readnone { + %x = add <16 x i8> %i, %j + ret <16 x i8> %x +} + +; CHECK-LABEL: vpaddb128_fold_test +; CHECK: vpaddb (%rdi), %xmm{{.*}} +; CHECK: ret +define <16 x i8> @vpaddb128_fold_test(<16 x i8> %i, <16 x i8>* %j) nounwind { + %tmp = load <16 x i8>* %j, align 4 + %x = add <16 x i8> %i, %tmp + ret <16 x i8> %x +} + +; CHECK-LABEL: vpaddw128_test +; CHECK: vpaddw %xmm{{.*}} +; CHECK: ret +define <8 x i16> @vpaddw128_test(<8 x i16> %i, <8 x i16> %j) nounwind readnone { + %x = add <8 x i16> %i, %j + ret <8 x i16> %x +} + +; CHECK-LABEL: vpaddw128_fold_test +; CHECK: vpaddw (%rdi), %xmm{{.*}} +; CHECK: ret +define <8 x i16> @vpaddw128_fold_test(<8 x i16> %i, <8 x i16>* %j) nounwind { + %tmp = load <8 x i16>* %j, align 4 + %x = add <8 x i16> %i, %tmp + ret <8 x i16> %x +} + +; CHECK-LABEL: vpaddw128_mask_test +; CHECK: vpaddw %xmm{{.*%k[1-7].*}} +; CHECK: ret +define <8 x i16> @vpaddw128_mask_test(<8 x i16> %i, <8 x i16> %j, <8 x i16> %mask1) nounwind readnone { + %mask = icmp ne <8 x i16> %mask1, zeroinitializer + %x = add <8 x i16> %i, %j + %r = select <8 x i1> %mask, <8 x i16> %x, <8 x i16> %i + ret <8 x i16> %r +} + +; CHECK-LABEL: vpaddw128_maskz_test +; CHECK: vpaddw %xmm{{.*{%k[1-7]} {z}.*}} +; CHECK: ret +define <8 x i16> @vpaddw128_maskz_test(<8 x i16> %i, <8 x i16> %j, <8 x i16> %mask1) nounwind readnone { + %mask = icmp ne <8 x i16> %mask1, zeroinitializer + %x = add <8 x i16> %i, %j + %r = select <8 x i1> %mask, <8 x i16> %x, <8 x i16> zeroinitializer + ret <8 x i16> %r +} + +; CHECK-LABEL: vpaddw128_mask_fold_test +; CHECK: vpaddw (%rdi), %xmm{{.*%k[1-7]}} +; CHECK: ret +define <8 x i16> @vpaddw128_mask_fold_test(<8 x i16> %i, <8 x i16>* %j.ptr, <8 x i16> %mask1) nounwind readnone { + %mask = icmp ne <8 x i16> %mask1, zeroinitializer + %j = load <8 x i16>* %j.ptr + %x = add <8 x i16> %i, %j + %r = select <8 x i1> %mask, <8 x i16> %x, <8 x i16> %i + ret <8 x i16> %r +} + +; CHECK-LABEL: vpaddw128_maskz_fold_test +; CHECK: vpaddw (%rdi), %xmm{{.*{%k[1-7]} {z}}} +; CHECK: ret +define <8 x i16> @vpaddw128_maskz_fold_test(<8 x i16> %i, <8 x i16>* %j.ptr, <8 x i16> %mask1) nounwind readnone { + %mask = icmp ne <8 x i16> %mask1, zeroinitializer + %j = load <8 x i16>* %j.ptr + %x = add <8 x i16> %i, %j + %r = select <8 x i1> %mask, <8 x i16> %x, <8 x i16> zeroinitializer + ret <8 x i16> %r +} + +; CHECK-LABEL: vpsubb128_test +; CHECK: vpsubb %xmm{{.*}} +; CHECK: ret +define <16 x i8> @vpsubb128_test(<16 x i8> %i, <16 x i8> %j) nounwind readnone { + %x = sub <16 x i8> %i, %j + ret <16 x i8> %x +} + +; CHECK-LABEL: vpsubw128_test +; CHECK: vpsubw %xmm{{.*}} +; CHECK: ret +define <8 x i16> @vpsubw128_test(<8 x i16> %i, <8 x i16> %j) nounwind readnone { + %x = sub <8 x i16> %i, %j + ret <8 x i16> %x +} + +; CHECK-LABEL: vpmullw128_test +; CHECK: vpmullw %xmm{{.*}} +; CHECK: ret +define <8 x i16> @vpmullw128_test(<8 x i16> %i, <8 x i16> %j) { + %x = mul <8 x i16> %i, %j + ret <8 x i16> %x +} + diff --git a/llvm/test/CodeGen/X86/avx512vl-arith.ll b/llvm/test/CodeGen/X86/avx512vl-arith.ll new file mode 100644 index 0000000..e6fb9ae --- /dev/null +++ b/llvm/test/CodeGen/X86/avx512vl-arith.ll @@ -0,0 +1,291 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=knl -mattr=+avx512vl| FileCheck %s + +; 256-bit + +; CHECK-LABEL: vpaddq256_test +; CHECK: vpaddq %ymm{{.*}} +; CHECK: ret +define <4 x i64> @vpaddq256_test(<4 x i64> %i, <4 x i64> %j) nounwind readnone { + %x = add <4 x i64> %i, %j + ret <4 x i64> %x +} + +; CHECK-LABEL: vpaddq256_fold_test +; CHECK: vpaddq (%rdi), %ymm{{.*}} +; CHECK: ret +define <4 x i64> @vpaddq256_fold_test(<4 x i64> %i, <4 x i64>* %j) nounwind { + %tmp = load <4 x i64>* %j, align 4 + %x = add <4 x i64> %i, %tmp + ret <4 x i64> %x +} + +; CHECK-LABEL: vpaddq256_broadcast_test +; CHECK: vpaddq LCP{{.*}}(%rip){1to4}, %ymm{{.*}} +; CHECK: ret +define <4 x i64> @vpaddq256_broadcast_test(<4 x i64> %i) nounwind { + %x = add <4 x i64> %i, + ret <4 x i64> %x +} + +; CHECK-LABEL: vpaddq256_broadcast2_test +; CHECK: vpaddq (%rdi){1to4}, %ymm{{.*}} +; CHECK: ret +define <4 x i64> @vpaddq256_broadcast2_test(<4 x i64> %i, i64* %j.ptr) nounwind { + %j = load i64* %j.ptr + %j.0 = insertelement <4 x i64> undef, i64 %j, i32 0 + %j.v = shufflevector <4 x i64> %j.0, <4 x i64> undef, <4 x i32> zeroinitializer + %x = add <4 x i64> %i, %j.v + ret <4 x i64> %x +} + +; CHECK-LABEL: vpaddd256_test +; CHECK: vpaddd %ymm{{.*}} +; CHECK: ret +define <8 x i32> @vpaddd256_test(<8 x i32> %i, <8 x i32> %j) nounwind readnone { + %x = add <8 x i32> %i, %j + ret <8 x i32> %x +} + +; CHECK-LABEL: vpaddd256_fold_test +; CHECK: vpaddd (%rdi), %ymm{{.*}} +; CHECK: ret +define <8 x i32> @vpaddd256_fold_test(<8 x i32> %i, <8 x i32>* %j) nounwind { + %tmp = load <8 x i32>* %j, align 4 + %x = add <8 x i32> %i, %tmp + ret <8 x i32> %x +} + +; CHECK-LABEL: vpaddd256_broadcast_test +; CHECK: vpaddd LCP{{.*}}(%rip){1to8}, %ymm{{.*}} +; CHECK: ret +define <8 x i32> @vpaddd256_broadcast_test(<8 x i32> %i) nounwind { + %x = add <8 x i32> %i, + ret <8 x i32> %x +} + +; CHECK-LABEL: vpaddd256_mask_test +; CHECK: vpaddd %ymm{{.*%k[1-7].*}} +; CHECK: ret +define <8 x i32> @vpaddd256_mask_test(<8 x i32> %i, <8 x i32> %j, <8 x i32> %mask1) nounwind readnone { + %mask = icmp ne <8 x i32> %mask1, zeroinitializer + %x = add <8 x i32> %i, %j + %r = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> %i + ret <8 x i32> %r +} + +; CHECK-LABEL: vpaddd256_maskz_test +; CHECK: vpaddd %ymm{{.*{%k[1-7]} {z}.*}} +; CHECK: ret +define <8 x i32> @vpaddd256_maskz_test(<8 x i32> %i, <8 x i32> %j, <8 x i32> %mask1) nounwind readnone { + %mask = icmp ne <8 x i32> %mask1, zeroinitializer + %x = add <8 x i32> %i, %j + %r = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> zeroinitializer + ret <8 x i32> %r +} + +; CHECK-LABEL: vpaddd256_mask_fold_test +; CHECK: vpaddd (%rdi), %ymm{{.*%k[1-7]}} +; CHECK: ret +define <8 x i32> @vpaddd256_mask_fold_test(<8 x i32> %i, <8 x i32>* %j.ptr, <8 x i32> %mask1) nounwind readnone { + %mask = icmp ne <8 x i32> %mask1, zeroinitializer + %j = load <8 x i32>* %j.ptr + %x = add <8 x i32> %i, %j + %r = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> %i + ret <8 x i32> %r +} + +; CHECK-LABEL: vpaddd256_mask_broadcast_test +; CHECK: vpaddd LCP{{.*}}(%rip){1to8}, %ymm{{.*{%k[1-7]}}} +; CHECK: ret +define <8 x i32> @vpaddd256_mask_broadcast_test(<8 x i32> %i, <8 x i32> %mask1) nounwind readnone { + %mask = icmp ne <8 x i32> %mask1, zeroinitializer + %x = add <8 x i32> %i, + %r = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> %i + ret <8 x i32> %r +} + +; CHECK-LABEL: vpaddd256_maskz_fold_test +; CHECK: vpaddd (%rdi), %ymm{{.*{%k[1-7]} {z}}} +; CHECK: ret +define <8 x i32> @vpaddd256_maskz_fold_test(<8 x i32> %i, <8 x i32>* %j.ptr, <8 x i32> %mask1) nounwind readnone { + %mask = icmp ne <8 x i32> %mask1, zeroinitializer + %j = load <8 x i32>* %j.ptr + %x = add <8 x i32> %i, %j + %r = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> zeroinitializer + ret <8 x i32> %r +} + +; CHECK-LABEL: vpaddd256_maskz_broadcast_test +; CHECK: vpaddd LCP{{.*}}(%rip){1to8}, %ymm{{.*{%k[1-7]} {z}}} +; CHECK: ret +define <8 x i32> @vpaddd256_maskz_broadcast_test(<8 x i32> %i, <8 x i32> %mask1) nounwind readnone { + %mask = icmp ne <8 x i32> %mask1, zeroinitializer + %x = add <8 x i32> %i, + %r = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> zeroinitializer + ret <8 x i32> %r +} + +; CHECK-LABEL: vpsubq256_test +; CHECK: vpsubq %ymm{{.*}} +; CHECK: ret +define <4 x i64> @vpsubq256_test(<4 x i64> %i, <4 x i64> %j) nounwind readnone { + %x = sub <4 x i64> %i, %j + ret <4 x i64> %x +} + +; CHECK-LABEL: vpsubd256_test +; CHECK: vpsubd %ymm{{.*}} +; CHECK: ret +define <8 x i32> @vpsubd256_test(<8 x i32> %i, <8 x i32> %j) nounwind readnone { + %x = sub <8 x i32> %i, %j + ret <8 x i32> %x +} + +; CHECK-LABEL: vpmulld256_test +; CHECK: vpmulld %ymm{{.*}} +; CHECK: ret +define <8 x i32> @vpmulld256_test(<8 x i32> %i, <8 x i32> %j) { + %x = mul <8 x i32> %i, %j + ret <8 x i32> %x +} + +; 128-bit + +; CHECK-LABEL: vpaddq128_test +; CHECK: vpaddq %xmm{{.*}} +; CHECK: ret +define <2 x i64> @vpaddq128_test(<2 x i64> %i, <2 x i64> %j) nounwind readnone { + %x = add <2 x i64> %i, %j + ret <2 x i64> %x +} + +; CHECK-LABEL: vpaddq128_fold_test +; CHECK: vpaddq (%rdi), %xmm{{.*}} +; CHECK: ret +define <2 x i64> @vpaddq128_fold_test(<2 x i64> %i, <2 x i64>* %j) nounwind { + %tmp = load <2 x i64>* %j, align 4 + %x = add <2 x i64> %i, %tmp + ret <2 x i64> %x +} + +; CHECK-LABEL: vpaddq128_broadcast2_test +; CHECK: vpaddq (%rdi){1to2}, %xmm{{.*}} +; CHECK: ret +define <2 x i64> @vpaddq128_broadcast2_test(<2 x i64> %i, i64* %j) nounwind { + %tmp = load i64* %j + %j.0 = insertelement <2 x i64> undef, i64 %tmp, i32 0 + %j.1 = insertelement <2 x i64> %j.0, i64 %tmp, i32 1 + %x = add <2 x i64> %i, %j.1 + ret <2 x i64> %x +} + +; CHECK-LABEL: vpaddd128_test +; CHECK: vpaddd %xmm{{.*}} +; CHECK: ret +define <4 x i32> @vpaddd128_test(<4 x i32> %i, <4 x i32> %j) nounwind readnone { + %x = add <4 x i32> %i, %j + ret <4 x i32> %x +} + +; CHECK-LABEL: vpaddd128_fold_test +; CHECK: vpaddd (%rdi), %xmm{{.*}} +; CHECK: ret +define <4 x i32> @vpaddd128_fold_test(<4 x i32> %i, <4 x i32>* %j) nounwind { + %tmp = load <4 x i32>* %j, align 4 + %x = add <4 x i32> %i, %tmp + ret <4 x i32> %x +} + +; CHECK-LABEL: vpaddd128_broadcast_test +; CHECK: vpaddd LCP{{.*}}(%rip){1to4}, %xmm{{.*}} +; CHECK: ret +define <4 x i32> @vpaddd128_broadcast_test(<4 x i32> %i) nounwind { + %x = add <4 x i32> %i, + ret <4 x i32> %x +} + +; CHECK-LABEL: vpaddd128_mask_test +; CHECK: vpaddd %xmm{{.*%k[1-7].*}} +; CHECK: ret +define <4 x i32> @vpaddd128_mask_test(<4 x i32> %i, <4 x i32> %j, <4 x i32> %mask1) nounwind readnone { + %mask = icmp ne <4 x i32> %mask1, zeroinitializer + %x = add <4 x i32> %i, %j + %r = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> %i + ret <4 x i32> %r +} + +; CHECK-LABEL: vpaddd128_maskz_test +; CHECK: vpaddd %xmm{{.*{%k[1-7]} {z}.*}} +; CHECK: ret +define <4 x i32> @vpaddd128_maskz_test(<4 x i32> %i, <4 x i32> %j, <4 x i32> %mask1) nounwind readnone { + %mask = icmp ne <4 x i32> %mask1, zeroinitializer + %x = add <4 x i32> %i, %j + %r = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> zeroinitializer + ret <4 x i32> %r +} + +; CHECK-LABEL: vpaddd128_mask_fold_test +; CHECK: vpaddd (%rdi), %xmm{{.*%k[1-7]}} +; CHECK: ret +define <4 x i32> @vpaddd128_mask_fold_test(<4 x i32> %i, <4 x i32>* %j.ptr, <4 x i32> %mask1) nounwind readnone { + %mask = icmp ne <4 x i32> %mask1, zeroinitializer + %j = load <4 x i32>* %j.ptr + %x = add <4 x i32> %i, %j + %r = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> %i + ret <4 x i32> %r +} + +; CHECK-LABEL: vpaddd128_mask_broadcast_test +; CHECK: vpaddd LCP{{.*}}(%rip){1to4}, %xmm{{.*{%k[1-7]}}} +; CHECK: ret +define <4 x i32> @vpaddd128_mask_broadcast_test(<4 x i32> %i, <4 x i32> %mask1) nounwind readnone { + %mask = icmp ne <4 x i32> %mask1, zeroinitializer + %x = add <4 x i32> %i, + %r = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> %i + ret <4 x i32> %r +} + +; CHECK-LABEL: vpaddd128_maskz_fold_test +; CHECK: vpaddd (%rdi), %xmm{{.*{%k[1-7]} {z}}} +; CHECK: ret +define <4 x i32> @vpaddd128_maskz_fold_test(<4 x i32> %i, <4 x i32>* %j.ptr, <4 x i32> %mask1) nounwind readnone { + %mask = icmp ne <4 x i32> %mask1, zeroinitializer + %j = load <4 x i32>* %j.ptr + %x = add <4 x i32> %i, %j + %r = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> zeroinitializer + ret <4 x i32> %r +} + +; CHECK-LABEL: vpaddd128_maskz_broadcast_test +; CHECK: vpaddd LCP{{.*}}(%rip){1to4}, %xmm{{.*{%k[1-7]} {z}}} +; CHECK: ret +define <4 x i32> @vpaddd128_maskz_broadcast_test(<4 x i32> %i, <4 x i32> %mask1) nounwind readnone { + %mask = icmp ne <4 x i32> %mask1, zeroinitializer + %x = add <4 x i32> %i, + %r = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> zeroinitializer + ret <4 x i32> %r +} + +; CHECK-LABEL: vpsubq128_test +; CHECK: vpsubq %xmm{{.*}} +; CHECK: ret +define <2 x i64> @vpsubq128_test(<2 x i64> %i, <2 x i64> %j) nounwind readnone { + %x = sub <2 x i64> %i, %j + ret <2 x i64> %x +} + +; CHECK-LABEL: vpsubd128_test +; CHECK: vpsubd %xmm{{.*}} +; CHECK: ret +define <4 x i32> @vpsubd128_test(<4 x i32> %i, <4 x i32> %j) nounwind readnone { + %x = sub <4 x i32> %i, %j + ret <4 x i32> %x +} + +; CHECK-LABEL: vpmulld128_test +; CHECK: vpmulld %xmm{{.*}} +; CHECK: ret +define <4 x i32> @vpmulld128_test(<4 x i32> %i, <4 x i32> %j) { + %x = mul <4 x i32> %i, %j + ret <4 x i32> %x +} -- 2.7.4