1 ; RUN: llc < %s -march=x86-64 -mattr=+avx2 | FileCheck %s 2 3 ; CHECK-LABEL: phaddw1: 4 ; CHECK: vphaddw 5 define <16 x i16> @phaddw1(<16 x i16> %x, <16 x i16> %y) { 6 %a = shufflevector <16 x i16> %x, <16 x i16> %y, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 8, i32 10, i32 12, i32 14, i32 24, i32 26, i32 28, i32 30> 7 %b = shufflevector <16 x i16> %x, <16 x i16> %y, <16 x i32> <i32 1, i32 3, i32 5, i32 7, i32 17, i32 19, i32 21, i32 23, i32 9, i32 11, i32 13, i32 15, i32 25, i32 27, i32 29, i32 31> 8 %r = add <16 x i16> %a, %b 9 ret <16 x i16> %r 10 } 11 12 ; CHECK-LABEL: phaddw2: 13 ; CHECK: vphaddw 14 define <16 x i16> @phaddw2(<16 x i16> %x, <16 x i16> %y) { 15 %a = shufflevector <16 x i16> %x, <16 x i16> %y, <16 x i32> <i32 1, i32 3, i32 5, i32 7, i32 17, i32 19, i32 21, i32 23, i32 9, i32 11, i32 13, i32 15, i32 25, i32 27, i32 29, i32 31> 16 %b = shufflevector <16 x i16> %y, <16 x i16> %x, <16 x i32> <i32 16, i32 18, i32 20, i32 22, i32 0, i32 2, i32 4, i32 6, i32 24, i32 26, i32 28, i32 30, i32 8, i32 10, i32 12, i32 14> 17 %r = add <16 x i16> %a, %b 18 ret <16 x i16> %r 19 } 20 21 ; CHECK-LABEL: phaddd1: 22 ; CHECK: vphaddd 23 define <8 x i32> @phaddd1(<8 x i32> %x, <8 x i32> %y) { 24 %a = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 0, i32 2, i32 8, i32 10, i32 4, i32 6, i32 12, i32 14> 25 %b = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 1, i32 3, i32 9, i32 11, i32 5, i32 7, i32 13, i32 15> 26 %r = add <8 x i32> %a, %b 27 ret <8 x i32> %r 28 } 29 30 ; CHECK-LABEL: phaddd2: 31 ; CHECK: vphaddd 32 define <8 x i32> @phaddd2(<8 x i32> %x, <8 x i32> %y) { 33 %a = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 1, i32 2, i32 9, i32 10, i32 5, i32 6, i32 13, i32 14> 34 %b = shufflevector <8 x i32> %y, <8 x i32> %x, <8 x i32> <i32 8, i32 11, i32 0, i32 3, i32 12, i32 15, i32 4, i32 7> 35 %r = add <8 x i32> %a, %b 36 ret <8 x i32> %r 37 } 38 39 ; CHECK-LABEL: phaddd3: 40 ; CHECK: vphaddd 41 define <8 x i32> @phaddd3(<8 x i32> %x) { 42 %a = shufflevector <8 x i32> %x, <8 x i32> undef, <8 x i32> <i32 undef, i32 2, i32 8, i32 10, i32 4, i32 6, i32 undef, i32 14> 43 %b = shufflevector <8 x i32> %x, <8 x i32> undef, <8 x i32> <i32 1, i32 3, i32 9, i32 undef, i32 5, i32 7, i32 13, i32 15> 44 %r = add <8 x i32> %a, %b 45 ret <8 x i32> %r 46 } 47 48 ; CHECK-LABEL: phsubw1: 49 ; CHECK: vphsubw 50 define <16 x i16> @phsubw1(<16 x i16> %x, <16 x i16> %y) { 51 %a = shufflevector <16 x i16> %x, <16 x i16> %y, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 8, i32 10, i32 12, i32 14, i32 24, i32 26, i32 28, i32 30> 52 %b = shufflevector <16 x i16> %x, <16 x i16> %y, <16 x i32> <i32 1, i32 3, i32 5, i32 7, i32 17, i32 19, i32 21, i32 23, i32 9, i32 11, i32 13, i32 15, i32 25, i32 27, i32 29, i32 31> 53 %r = sub <16 x i16> %a, %b 54 ret <16 x i16> %r 55 } 56 57 ; CHECK-LABEL: phsubd1: 58 ; CHECK: vphsubd 59 define <8 x i32> @phsubd1(<8 x i32> %x, <8 x i32> %y) { 60 %a = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 0, i32 2, i32 8, i32 10, i32 4, i32 6, i32 12, i32 14> 61 %b = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 1, i32 3, i32 9, i32 11, i32 5, i32 7, i32 13, i32 15> 62 %r = sub <8 x i32> %a, %b 63 ret <8 x i32> %r 64 } 65 66 ; CHECK-LABEL: phsubd2: 67 ; CHECK: vphsubd 68 define <8 x i32> @phsubd2(<8 x i32> %x, <8 x i32> %y) { 69 %a = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 0, i32 undef, i32 8, i32 undef, i32 4, i32 6, i32 12, i32 14> 70 %b = shufflevector <8 x i32> %x, <8 x i32> %y, <8 x i32> <i32 1, i32 undef, i32 9, i32 11, i32 5, i32 7, i32 undef, i32 15> 71 %r = sub <8 x i32> %a, %b 72 ret <8 x i32> %r 73 } 74