Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py |
| 2 | ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+ssse3 | FileCheck %s --check-prefix=SSSE3 |
| 3 | ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx | FileCheck %s --check-prefix=AVX |
| 4 | |
| 5 | ; The next 8 tests check for matching the horizontal op and eliminating the shuffle. |
| 6 | ; PR34111 - https://bugs.llvm.org/show_bug.cgi?id=34111 |
| 7 | |
| 8 | define <4 x float> @hadd_v4f32(<4 x float> %a) { |
| 9 | ; SSSE3-LABEL: hadd_v4f32: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 10 | ; SSSE3: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 11 | ; SSSE3-NEXT: haddps %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 12 | ; SSSE3-NEXT: retq |
| 13 | ; |
| 14 | ; AVX-LABEL: hadd_v4f32: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 15 | ; AVX: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 16 | ; AVX-NEXT: vhaddps %xmm0, %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 17 | ; AVX-NEXT: retq |
| 18 | %a02 = shufflevector <4 x float> %a, <4 x float> undef, <2 x i32> <i32 0, i32 2> |
| 19 | %a13 = shufflevector <4 x float> %a, <4 x float> undef, <2 x i32> <i32 1, i32 3> |
| 20 | %hop = fadd <2 x float> %a02, %a13 |
| 21 | %shuf = shufflevector <2 x float> %hop, <2 x float> undef, <4 x i32> <i32 undef, i32 undef, i32 0, i32 1> |
| 22 | ret <4 x float> %shuf |
| 23 | } |
| 24 | |
| 25 | define <4 x float> @hsub_v4f32(<4 x float> %a) { |
| 26 | ; SSSE3-LABEL: hsub_v4f32: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 27 | ; SSSE3: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 28 | ; SSSE3-NEXT: hsubps %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 29 | ; SSSE3-NEXT: retq |
| 30 | ; |
| 31 | ; AVX-LABEL: hsub_v4f32: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 32 | ; AVX: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 33 | ; AVX-NEXT: vhsubps %xmm0, %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 34 | ; AVX-NEXT: retq |
| 35 | %a02 = shufflevector <4 x float> %a, <4 x float> undef, <2 x i32> <i32 0, i32 2> |
| 36 | %a13 = shufflevector <4 x float> %a, <4 x float> undef, <2 x i32> <i32 1, i32 3> |
| 37 | %hop = fsub <2 x float> %a02, %a13 |
| 38 | %shuf = shufflevector <2 x float> %hop, <2 x float> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 1> |
| 39 | ret <4 x float> %shuf |
| 40 | } |
| 41 | |
| 42 | define <2 x double> @hadd_v2f64(<2 x double> %a) { |
| 43 | ; SSSE3-LABEL: hadd_v2f64: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 44 | ; SSSE3: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 45 | ; SSSE3-NEXT: haddpd %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 46 | ; SSSE3-NEXT: retq |
| 47 | ; |
| 48 | ; AVX-LABEL: hadd_v2f64: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 49 | ; AVX: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 50 | ; AVX-NEXT: vhaddpd %xmm0, %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 51 | ; AVX-NEXT: retq |
| 52 | %a0 = shufflevector <2 x double> %a, <2 x double> undef, <2 x i32> <i32 0, i32 undef> |
| 53 | %a1 = shufflevector <2 x double> %a, <2 x double> undef, <2 x i32> <i32 1, i32 undef> |
| 54 | %hop = fadd <2 x double> %a0, %a1 |
| 55 | %shuf = shufflevector <2 x double> %hop, <2 x double> undef, <2 x i32> <i32 0, i32 0> |
| 56 | ret <2 x double> %shuf |
| 57 | } |
| 58 | |
| 59 | define <2 x double> @hsub_v2f64(<2 x double> %a) { |
| 60 | ; SSSE3-LABEL: hsub_v2f64: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 61 | ; SSSE3: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 62 | ; SSSE3-NEXT: hsubpd %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 63 | ; SSSE3-NEXT: retq |
| 64 | ; |
| 65 | ; AVX-LABEL: hsub_v2f64: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 66 | ; AVX: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 67 | ; AVX-NEXT: vhsubpd %xmm0, %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 68 | ; AVX-NEXT: retq |
| 69 | %a0 = shufflevector <2 x double> %a, <2 x double> undef, <2 x i32> <i32 0, i32 undef> |
| 70 | %a1 = shufflevector <2 x double> %a, <2 x double> undef, <2 x i32> <i32 1, i32 undef> |
| 71 | %hop = fsub <2 x double> %a0, %a1 |
| 72 | %shuf = shufflevector <2 x double> %hop, <2 x double> undef, <2 x i32> <i32 undef, i32 0> |
| 73 | ret <2 x double> %shuf |
| 74 | } |
| 75 | |
| 76 | define <4 x i32> @hadd_v4i32(<4 x i32> %a) { |
| 77 | ; SSSE3-LABEL: hadd_v4i32: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 78 | ; SSSE3: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 79 | ; SSSE3-NEXT: phaddd %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 80 | ; SSSE3-NEXT: retq |
| 81 | ; |
| 82 | ; AVX-LABEL: hadd_v4i32: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 83 | ; AVX: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 84 | ; AVX-NEXT: vphaddd %xmm0, %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 85 | ; AVX-NEXT: retq |
| 86 | %a02 = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> |
| 87 | %a13 = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> |
| 88 | %hop = add <4 x i32> %a02, %a13 |
| 89 | %shuf = shufflevector <4 x i32> %hop, <4 x i32> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 1> |
| 90 | ret <4 x i32> %shuf |
| 91 | } |
| 92 | |
| 93 | define <4 x i32> @hsub_v4i32(<4 x i32> %a) { |
| 94 | ; SSSE3-LABEL: hsub_v4i32: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 95 | ; SSSE3: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 96 | ; SSSE3-NEXT: phsubd %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 97 | ; SSSE3-NEXT: retq |
| 98 | ; |
| 99 | ; AVX-LABEL: hsub_v4i32: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 100 | ; AVX: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 101 | ; AVX-NEXT: vphsubd %xmm0, %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 102 | ; AVX-NEXT: retq |
| 103 | %a02 = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> |
| 104 | %a13 = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> |
| 105 | %hop = sub <4 x i32> %a02, %a13 |
| 106 | %shuf = shufflevector <4 x i32> %hop, <4 x i32> undef, <4 x i32> <i32 undef, i32 1, i32 0, i32 undef> |
| 107 | ret <4 x i32> %shuf |
| 108 | } |
| 109 | |
| 110 | define <8 x i16> @hadd_v8i16(<8 x i16> %a) { |
| 111 | ; SSSE3-LABEL: hadd_v8i16: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 112 | ; SSSE3: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 113 | ; SSSE3-NEXT: phaddw %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 114 | ; SSSE3-NEXT: retq |
| 115 | ; |
| 116 | ; AVX-LABEL: hadd_v8i16: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 117 | ; AVX: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 118 | ; AVX-NEXT: vphaddw %xmm0, %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 119 | ; AVX-NEXT: retq |
| 120 | %a0246 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 0, i32 2, i32 4, i32 6, i32 undef, i32 undef, i32 undef, i32 undef> |
| 121 | %a1357 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 1, i32 3, i32 5, i32 7, i32 undef, i32 undef, i32 undef, i32 undef> |
| 122 | %hop = add <8 x i16> %a0246, %a1357 |
| 123 | %shuf = shufflevector <8 x i16> %hop, <8 x i16> undef, <8 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 0, i32 1, i32 2, i32 3> |
| 124 | ret <8 x i16> %shuf |
| 125 | } |
| 126 | |
| 127 | define <8 x i16> @hsub_v8i16(<8 x i16> %a) { |
| 128 | ; SSSE3-LABEL: hsub_v8i16: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 129 | ; SSSE3: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 130 | ; SSSE3-NEXT: phsubw %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 131 | ; SSSE3-NEXT: retq |
| 132 | ; |
| 133 | ; AVX-LABEL: hsub_v8i16: |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 134 | ; AVX: # %bb.0: |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 135 | ; AVX-NEXT: vphsubw %xmm0, %xmm0, %xmm0 |
Sanjay Patel | 841acbb | 2017-08-31 20:59:25 +0000 | [diff] [blame] | 136 | ; AVX-NEXT: retq |
| 137 | %a0246 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 0, i32 2, i32 4, i32 6, i32 undef, i32 undef, i32 undef, i32 undef> |
| 138 | %a1357 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> <i32 1, i32 3, i32 5, i32 7, i32 undef, i32 undef, i32 undef, i32 undef> |
| 139 | %hop = sub <8 x i16> %a0246, %a1357 |
| 140 | %shuf = shufflevector <8 x i16> %hop, <8 x i16> undef, <8 x i32> <i32 0, i32 undef, i32 2, i32 undef, i32 undef, i32 1, i32 undef, i32 3> |
| 141 | ret <8 x i16> %shuf |
| 142 | } |
| 143 | |