Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals -wasm-enable-unimplemented-simd -mattr=+simd128,+sign-ext --show-mc-encoding | FileCheck %s --check-prefixes CHECK,SIMD128 |
| 2 | ; RUN: llc < %s -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals -mattr=+simd128,+sign-ext --show-mc-encoding | FileCheck %s --check-prefixes CHECK,SIMD128-VM |
| 3 | ; RUN: llc < %s -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals -mattr=-simd128,+sign-ext --show-mc-encoding | FileCheck %s --check-prefixes CHECK,NO-SIMD128 |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 4 | |
| 5 | ; Test that basic SIMD128 vector manipulation operations assemble as expected. |
| 6 | |
| 7 | target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" |
| 8 | target triple = "wasm32-unknown-unknown" |
| 9 | |
| 10 | ; ============================================================================== |
| 11 | ; 16 x i8 |
| 12 | ; ============================================================================== |
Derek Schuff | 4ec8bca | 2018-08-15 00:30:27 +0000 | [diff] [blame] | 13 | ; CHECK-LABEL: splat_v16i8: |
| 14 | ; NO-SIMD128-NOT: i8x16 |
| 15 | ; SIMD128: .param i32{{$}} |
| 16 | ; SIMD128: .result v128{{$}} |
| 17 | ; SIMD128: i8x16.splat $push0=, $0 # encoding: [0xfd,0x03]{{$}} |
| 18 | ; SIMD128: return $pop0 # encoding: [0x0f]{{$}} |
| 19 | define <16 x i8> @splat_v16i8(i8 %x) { |
| 20 | %v = insertelement <16 x i8> undef, i8 %x, i32 0 |
| 21 | %res = shufflevector <16 x i8> %v, <16 x i8> undef, |
| 22 | <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, |
| 23 | i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0> |
| 24 | ret <16 x i8> %res |
| 25 | } |
| 26 | |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 27 | ; CHECK-LABEL: extract_v16i8_s: |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 28 | ; NO-SIMD128-NOT: i8x16 |
| 29 | ; SIMD128: .param v128{{$}} |
| 30 | ; SIMD128: .result i32{{$}} |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 31 | ; SIMD128: i8x16.extract_lane_s $push0=, $0, 13 # encoding: [0xfd,0x09,0x0d]{{$}} |
| 32 | ; SIMD128: return $pop0 # |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 33 | define i32 @extract_v16i8_s(<16 x i8> %v) { |
| 34 | %elem = extractelement <16 x i8> %v, i8 13 |
| 35 | %a = sext i8 %elem to i32 |
| 36 | ret i32 %a |
| 37 | } |
| 38 | |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 39 | ; CHECK-LABEL: extract_v16i8_u: |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 40 | ; NO-SIMD128-NOT: i8x16 |
| 41 | ; SIMD128: .param v128{{$}} |
| 42 | ; SIMD128: .result i32{{$}} |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 43 | ; SIMD128: i8x16.extract_lane_u $push0=, $0, 13 # encoding: [0xfd,0x0a,0x0d]{{$}} |
| 44 | ; SIMD128: return $pop0 # |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 45 | define i32 @extract_v16i8_u(<16 x i8> %v) { |
| 46 | %elem = extractelement <16 x i8> %v, i8 13 |
| 47 | %a = zext i8 %elem to i32 |
| 48 | ret i32 %a |
| 49 | } |
| 50 | |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 51 | ; CHECK-LABEL: extract_v16i8: |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 52 | ; NO-SIMD128-NOT: i8x16 |
| 53 | ; SIMD128: .param v128{{$}} |
| 54 | ; SIMD128: .result i32{{$}} |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 55 | ; SIMD128: i8x16.extract_lane_u $push0=, $0, 13 # encoding: [0xfd,0x0a,0x0d]{{$}} |
| 56 | ; SIMD128: return $pop0 # |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 57 | define i8 @extract_v16i8(<16 x i8> %v) { |
| 58 | %elem = extractelement <16 x i8> %v, i8 13 |
| 59 | ret i8 %elem |
| 60 | } |
| 61 | |
| 62 | ; ============================================================================== |
| 63 | ; 8 x i16 |
| 64 | ; ============================================================================== |
Derek Schuff | 4ec8bca | 2018-08-15 00:30:27 +0000 | [diff] [blame] | 65 | ; CHECK-LABEL: splat_v8i16: |
| 66 | ; NO-SIMD128-NOT: i16x8 |
| 67 | ; SIMD128: .param i32{{$}} |
| 68 | ; SIMD128: .result v128{{$}} |
| 69 | ; SIMD128: i16x8.splat $push0=, $0 # encoding: [0xfd,0x04]{{$}} |
| 70 | ; SIMD128: return $pop0 # encoding: [0x0f]{{$}} |
| 71 | define <8 x i16> @splat_v8i16(i16 %x) { |
| 72 | %v = insertelement <8 x i16> undef, i16 %x, i32 0 |
| 73 | %res = shufflevector <8 x i16> %v, <8 x i16> undef, |
| 74 | <8 x i32> <i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0> |
| 75 | ret <8 x i16> %res |
| 76 | } |
| 77 | |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 78 | ; CHECK-LABEL: extract_v8i16_s: |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 79 | ; NO-SIMD128-NOT: i16x8 |
| 80 | ; SIMD128: .param v128{{$}} |
| 81 | ; SIMD128: .result i32{{$}} |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 82 | ; SIMD128: i16x8.extract_lane_s $push0=, $0, 5 # encoding: [0xfd,0x0b,0x05]{{$}} |
| 83 | ; SIMD128: return $pop0 # |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 84 | define i32 @extract_v8i16_s(<8 x i16> %v) { |
| 85 | %elem = extractelement <8 x i16> %v, i16 5 |
| 86 | %a = sext i16 %elem to i32 |
| 87 | ret i32 %a |
| 88 | } |
| 89 | |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 90 | ; CHECK-LABEL: extract_v8i16_u: |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 91 | ; NO-SIMD128-NOT: i16x8 |
| 92 | ; SIMD128: .param v128{{$}} |
| 93 | ; SIMD128: .result i32{{$}} |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 94 | ; SIMD128: i16x8.extract_lane_u $push0=, $0, 5 # encoding: [0xfd,0x0c,0x05]{{$}} |
| 95 | ; SIMD128: return $pop0 # |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 96 | define i32 @extract_v8i16_u(<8 x i16> %v) { |
| 97 | %elem = extractelement <8 x i16> %v, i16 5 |
| 98 | %a = zext i16 %elem to i32 |
| 99 | ret i32 %a |
| 100 | } |
| 101 | |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 102 | ; CHECK-LABEL: extract_v8i16: |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 103 | ; NO-SIMD128-NOT: i16x8 |
| 104 | ; SIMD128: .param v128{{$}} |
| 105 | ; SIMD128: .result i32{{$}} |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 106 | ; SIMD128: i16x8.extract_lane_u $push0=, $0, 5 # encoding: [0xfd,0x0c,0x05]{{$}} |
| 107 | ; SIMD128: return $pop0 # |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 108 | define i16 @extract_v8i16(<8 x i16> %v) { |
| 109 | %elem = extractelement <8 x i16> %v, i16 5 |
| 110 | ret i16 %elem |
| 111 | } |
| 112 | |
| 113 | ; ============================================================================== |
| 114 | ; 4 x i32 |
| 115 | ; ============================================================================== |
Derek Schuff | 4ec8bca | 2018-08-15 00:30:27 +0000 | [diff] [blame] | 116 | ; CHECK-LABEL: splat_v4i32: |
| 117 | ; NO-SIMD128-NOT: i32x4 |
| 118 | ; SIMD128: .param i32{{$}} |
| 119 | ; SIMD128: .result v128{{$}} |
| 120 | ; SIMD128: i32x4.splat $push0=, $0 # encoding: [0xfd,0x05]{{$}} |
| 121 | ; SIMD128: return $pop0 # encoding: [0x0f]{{$}} |
| 122 | define <4 x i32> @splat_v4i32(i32 %x) { |
| 123 | %v = insertelement <4 x i32> undef, i32 %x, i32 0 |
| 124 | %res = shufflevector <4 x i32> %v, <4 x i32> undef, |
| 125 | <4 x i32> <i32 0, i32 0, i32 0, i32 0> |
| 126 | ret <4 x i32> %res |
| 127 | } |
| 128 | |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 129 | ; CHECK-LABEL: extract_v4i32: |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 130 | ; NO-SIMD128-NOT: i32x4 |
| 131 | ; SIMD128: .param v128{{$}} |
| 132 | ; SIMD128: .result i32{{$}} |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 133 | ; SIMD128: i32x4.extract_lane $push0=, $0, 3 # encoding: [0xfd,0x0d,0x03]{{$}} |
| 134 | ; SIMD128: return $pop0 # |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 135 | define i32 @extract_v4i32(<4 x i32> %v) { |
| 136 | %elem = extractelement <4 x i32> %v, i32 3 |
| 137 | ret i32 %elem |
| 138 | } |
| 139 | |
| 140 | ; ============================================================================== |
| 141 | ; 2 x i64 |
| 142 | ; ============================================================================== |
Derek Schuff | 4ec8bca | 2018-08-15 00:30:27 +0000 | [diff] [blame] | 143 | ; CHECK-LABEL: splat_v2i64: |
| 144 | ; NO-SIMD128-NOT: i64x2 |
| 145 | ; SIMD128-VM-NOT: i64x2 |
| 146 | ; SIMD128: .param i64{{$}} |
| 147 | ; SIMD128: .result v128{{$}} |
| 148 | ; SIMD128: i64x2.splat $push0=, $0 # encoding: [0xfd,0x06]{{$}} |
| 149 | ; SIMD128: return $pop0 # encoding: [0x0f]{{$}} |
| 150 | define <2 x i64> @splat_v2i64(i64 %x) { |
| 151 | %t1 = insertelement <2 x i64> zeroinitializer, i64 %x, i32 0 |
| 152 | %res = insertelement <2 x i64> %t1, i64 %x, i32 1 |
| 153 | ret <2 x i64> %res |
| 154 | } |
| 155 | |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 156 | ; CHECK-LABEL: extract_v2i64: |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 157 | ; NO-SIMD128-NOT: i64x2 |
| 158 | ; SIMD128-VM-NOT: i64x2 |
| 159 | ; SIMD128: .param v128{{$}} |
| 160 | ; SIMD128: .result i64{{$}} |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 161 | ; SIMD128: i64x2.extract_lane $push0=, $0, 1 # encoding: [0xfd,0x0e,0x01]{{$}} |
| 162 | ; SIMD128: return $pop0 # |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 163 | define i64 @extract_v2i64(<2 x i64> %v) { |
| 164 | %elem = extractelement <2 x i64> %v, i64 1 |
| 165 | ret i64 %elem |
| 166 | } |
| 167 | |
| 168 | ; ============================================================================== |
| 169 | ; 4 x f32 |
| 170 | ; ============================================================================== |
Derek Schuff | 4ec8bca | 2018-08-15 00:30:27 +0000 | [diff] [blame] | 171 | ; CHECK-LABEL: splat_v4f32: |
| 172 | ; NO-SIMD128-NOT: f32x4 |
| 173 | ; SIMD128: .param f32{{$}} |
| 174 | ; SIMD128: .result v128{{$}} |
| 175 | ; SIMD128: f32x4.splat $push0=, $0 # encoding: [0xfd,0x07]{{$}} |
| 176 | ; SIMD128: return $pop0 # encoding: [0x0f]{{$}} |
| 177 | define <4 x float> @splat_v4f32(float %x) { |
| 178 | %v = insertelement <4 x float> undef, float %x, i32 0 |
| 179 | %res = shufflevector <4 x float> %v, <4 x float> undef, |
| 180 | <4 x i32> <i32 0, i32 0, i32 0, i32 0> |
| 181 | ret <4 x float> %res |
| 182 | } |
| 183 | |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 184 | ; CHECK-LABEL: extract_v4f32: |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 185 | ; NO-SIMD128-NOT: f32x4 |
| 186 | ; SIMD128: .param v128{{$}} |
| 187 | ; SIMD128: .result f32{{$}} |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 188 | ; SIMD128: f32x4.extract_lane $push0=, $0, 3 # encoding: [0xfd,0x0f,0x03]{{$}} |
| 189 | ; SIMD128: return $pop0 # |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 190 | define float @extract_v4f32(<4 x float> %v) { |
| 191 | %elem = extractelement <4 x float> %v, i32 3 |
| 192 | ret float %elem |
| 193 | } |
| 194 | |
| 195 | ; ============================================================================== |
| 196 | ; 2 x f64 |
| 197 | ; ============================================================================== |
Derek Schuff | 4ec8bca | 2018-08-15 00:30:27 +0000 | [diff] [blame] | 198 | ; CHECK-LABEL: splat_v2f64: |
| 199 | ; NO-SIMD128-NOT: f64x2 |
| 200 | ; SIMD128-VM-NOT: f64x2 |
| 201 | ; SIMD128: .param f64{{$}} |
| 202 | ; SIMD128: .result v128{{$}} |
| 203 | ; SIMD128: f64x2.splat $push0=, $0 # encoding: [0xfd,0x08]{{$}} |
| 204 | ; SIMD128: return $pop0 # encoding: [0x0f]{{$}} |
| 205 | define <2 x double> @splat_v2f64(double %x) { |
| 206 | %t1 = insertelement <2 x double> zeroinitializer, double %x, i3 0 |
| 207 | %res = insertelement <2 x double> %t1, double %x, i32 1 |
| 208 | ret <2 x double> %res |
| 209 | } |
| 210 | |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 211 | ; CHECK-LABEL: extract_v2f64: |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 212 | ; NO-SIMD128-NOT: f64x2 |
| 213 | ; SIMD128-VM-NOT: f64x2 |
| 214 | ; SIMD128: .param v128{{$}} |
| 215 | ; SIMD128: .result f64{{$}} |
Heejin Ahn | c15a878 | 2018-08-14 19:10:50 +0000 | [diff] [blame] | 216 | ; SIMD128: f64x2.extract_lane $push0=, $0, 1 # encoding: [0xfd,0x10,0x01]{{$}} |
| 217 | ; SIMD128: return $pop0 # |
Heejin Ahn | a0fd9c3 | 2018-08-14 18:53:27 +0000 | [diff] [blame] | 218 | define double @extract_v2f64(<2 x double> %v) { |
| 219 | %elem = extractelement <2 x double> %v, i32 1 |
| 220 | ret double %elem |
| 221 | } |