|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4 |
| 2 | +; RUN: llc < %s -mtriple=wasm32 -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 | FileCheck %s --check-prefix=SIMD128 |
| 3 | + |
| 4 | +define i64 @pairwise_add_v2i64(<2 x i64> %arg) { |
| 5 | +; SIMD128-LABEL: pairwise_add_v2i64: |
| 6 | +; SIMD128: .functype pairwise_add_v2i64 (v128) -> (i64) |
| 7 | +; SIMD128-NEXT: # %bb.0: |
| 8 | +; SIMD128-NEXT: i8x16.shuffle $push0=, $0, $0, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7 |
| 9 | +; SIMD128-NEXT: i64x2.add $push1=, $0, $pop0 |
| 10 | +; SIMD128-NEXT: i64x2.extract_lane $push2=, $pop1, 0 |
| 11 | +; SIMD128-NEXT: return $pop2 |
| 12 | + %res = tail call i64 @llvm.vector.reduce.add.i64.v4i64(<2 x i64> %arg) |
| 13 | + ret i64 %res |
| 14 | +} |
| 15 | + |
| 16 | +define i32 @pairwise_add_v4i32(<4 x i32> %arg) { |
| 17 | +; SIMD128-LABEL: pairwise_add_v4i32: |
| 18 | +; SIMD128: .functype pairwise_add_v4i32 (v128) -> (i32) |
| 19 | +; SIMD128-NEXT: # %bb.0: |
| 20 | +; SIMD128-NEXT: i8x16.shuffle $push0=, $0, $0, 4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 0, 1, 2, 3 |
| 21 | +; SIMD128-NEXT: i32x4.add $push5=, $0, $pop0 |
| 22 | +; SIMD128-NEXT: local.tee $push4=, $0=, $pop5 |
| 23 | +; SIMD128-NEXT: i8x16.shuffle $push1=, $0, $0, 8, 9, 10, 11, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3 |
| 24 | +; SIMD128-NEXT: i32x4.add $push2=, $pop4, $pop1 |
| 25 | +; SIMD128-NEXT: i32x4.extract_lane $push3=, $pop2, 0 |
| 26 | +; SIMD128-NEXT: return $pop3 |
| 27 | + %res = tail call i32 @llvm.vector.reduce.add.i32.v4f32(<4 x i32> %arg) |
| 28 | + ret i32 %res |
| 29 | +} |
| 30 | + |
| 31 | +define i16 @pairwise_add_v8i16(<8 x i16> %arg) { |
| 32 | +; SIMD128-LABEL: pairwise_add_v8i16: |
| 33 | +; SIMD128: .functype pairwise_add_v8i16 (v128) -> (i32) |
| 34 | +; SIMD128-NEXT: # %bb.0: |
| 35 | +; SIMD128-NEXT: i8x16.shuffle $push0=, $0, $0, 2, 3, 0, 1, 6, 7, 0, 1, 10, 11, 0, 1, 14, 15, 0, 1 |
| 36 | +; SIMD128-NEXT: i16x8.add $push8=, $0, $pop0 |
| 37 | +; SIMD128-NEXT: local.tee $push7=, $0=, $pop8 |
| 38 | +; SIMD128-NEXT: i8x16.shuffle $push1=, $0, $0, 4, 5, 0, 1, 0, 1, 0, 1, 12, 13, 0, 1, 0, 1, 0, 1 |
| 39 | +; SIMD128-NEXT: i16x8.add $push6=, $pop7, $pop1 |
| 40 | +; SIMD128-NEXT: local.tee $push5=, $0=, $pop6 |
| 41 | +; SIMD128-NEXT: i8x16.shuffle $push2=, $0, $0, 8, 9, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 |
| 42 | +; SIMD128-NEXT: i16x8.add $push3=, $pop5, $pop2 |
| 43 | +; SIMD128-NEXT: i16x8.extract_lane_u $push4=, $pop3, 0 |
| 44 | +; SIMD128-NEXT: return $pop4 |
| 45 | + %res = tail call i16 @llvm.vector.reduce.add.i16.v8i16(<8 x i16> %arg) |
| 46 | + ret i16 %res |
| 47 | +} |
| 48 | + |
| 49 | +define i8 @pairwise_add_v16i8(<16 x i8> %arg) { |
| 50 | +; SIMD128-LABEL: pairwise_add_v16i8: |
| 51 | +; SIMD128: .functype pairwise_add_v16i8 (v128) -> (i32) |
| 52 | +; SIMD128-NEXT: # %bb.0: |
| 53 | +; SIMD128-NEXT: i8x16.shuffle $push0=, $0, $0, 1, 0, 3, 0, 5, 0, 7, 0, 9, 0, 11, 0, 13, 0, 15, 0 |
| 54 | +; SIMD128-NEXT: i8x16.add $push11=, $0, $pop0 |
| 55 | +; SIMD128-NEXT: local.tee $push10=, $0=, $pop11 |
| 56 | +; SIMD128-NEXT: i8x16.shuffle $push1=, $0, $0, 2, 0, 0, 0, 6, 0, 0, 0, 10, 0, 0, 0, 14, 0, 0, 0 |
| 57 | +; SIMD128-NEXT: i8x16.add $push9=, $pop10, $pop1 |
| 58 | +; SIMD128-NEXT: local.tee $push8=, $0=, $pop9 |
| 59 | +; SIMD128-NEXT: i8x16.shuffle $push2=, $0, $0, 4, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0 |
| 60 | +; SIMD128-NEXT: i8x16.add $push7=, $pop8, $pop2 |
| 61 | +; SIMD128-NEXT: local.tee $push6=, $0=, $pop7 |
| 62 | +; SIMD128-NEXT: i8x16.shuffle $push3=, $0, $0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 63 | +; SIMD128-NEXT: i8x16.add $push4=, $pop6, $pop3 |
| 64 | +; SIMD128-NEXT: i8x16.extract_lane_u $push5=, $pop4, 0 |
| 65 | +; SIMD128-NEXT: return $pop5 |
| 66 | + %res = tail call i8 @llvm.vector.reduce.add.i8.v16i8(<16 x i8> %arg) |
| 67 | + ret i8 %res |
| 68 | +} |
| 69 | + |
| 70 | +define double @pairwise_add_v2f64(<2 x double> %arg) { |
| 71 | +; SIMD128-LABEL: pairwise_add_v2f64: |
| 72 | +; SIMD128: .functype pairwise_add_v2f64 (v128) -> (f64) |
| 73 | +; SIMD128-NEXT: # %bb.0: |
| 74 | +; SIMD128-NEXT: f64x2.extract_lane $push1=, $0, 0 |
| 75 | +; SIMD128-NEXT: f64x2.extract_lane $push0=, $0, 1 |
| 76 | +; SIMD128-NEXT: f64.add $push2=, $pop1, $pop0 |
| 77 | +; SIMD128-NEXT: return $pop2 |
| 78 | + %res = tail call double @llvm.vector.reduce.fadd.f64.v2f64(double -0.0, <2 x double> %arg) |
| 79 | + ret double%res |
| 80 | +} |
| 81 | + |
| 82 | +define double @pairwise_add_v2f64_fast(<2 x double> %arg) { |
| 83 | +; SIMD128-LABEL: pairwise_add_v2f64_fast: |
| 84 | +; SIMD128: .functype pairwise_add_v2f64_fast (v128) -> (f64) |
| 85 | +; SIMD128-NEXT: # %bb.0: |
| 86 | +; SIMD128-NEXT: i8x16.shuffle $push0=, $0, $0, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7 |
| 87 | +; SIMD128-NEXT: f64x2.add $push1=, $0, $pop0 |
| 88 | +; SIMD128-NEXT: f64x2.extract_lane $push2=, $pop1, 0 |
| 89 | +; SIMD128-NEXT: return $pop2 |
| 90 | + %res = tail call fast double @llvm.vector.reduce.fadd.f64.v2f64(double -0.0, <2 x double> %arg) |
| 91 | + ret double%res |
| 92 | +} |
| 93 | + |
| 94 | +define float @pairwise_add_v4f32(<4 x float> %arg) { |
| 95 | +; SIMD128-LABEL: pairwise_add_v4f32: |
| 96 | +; SIMD128: .functype pairwise_add_v4f32 (v128) -> (f32) |
| 97 | +; SIMD128-NEXT: # %bb.0: |
| 98 | +; SIMD128-NEXT: f32x4.extract_lane $push1=, $0, 0 |
| 99 | +; SIMD128-NEXT: f32x4.extract_lane $push0=, $0, 1 |
| 100 | +; SIMD128-NEXT: f32.add $push2=, $pop1, $pop0 |
| 101 | +; SIMD128-NEXT: f32x4.extract_lane $push3=, $0, 2 |
| 102 | +; SIMD128-NEXT: f32.add $push4=, $pop2, $pop3 |
| 103 | +; SIMD128-NEXT: f32x4.extract_lane $push5=, $0, 3 |
| 104 | +; SIMD128-NEXT: f32.add $push6=, $pop4, $pop5 |
| 105 | +; SIMD128-NEXT: return $pop6 |
| 106 | + %res = tail call float @llvm.vector.reduce.fadd.f32.v4f32(float -0.0, <4 x float> %arg) |
| 107 | + ret float %res |
| 108 | +} |
| 109 | + |
| 110 | +define float @pairwise_add_v4f32_fast(<4 x float> %arg) { |
| 111 | +; SIMD128-LABEL: pairwise_add_v4f32_fast: |
| 112 | +; SIMD128: .functype pairwise_add_v4f32_fast (v128) -> (f32) |
| 113 | +; SIMD128-NEXT: # %bb.0: |
| 114 | +; SIMD128-NEXT: i8x16.shuffle $push0=, $0, $0, 4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 0, 1, 2, 3 |
| 115 | +; SIMD128-NEXT: f32x4.add $push5=, $0, $pop0 |
| 116 | +; SIMD128-NEXT: local.tee $push4=, $0=, $pop5 |
| 117 | +; SIMD128-NEXT: i8x16.shuffle $push1=, $0, $0, 8, 9, 10, 11, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3 |
| 118 | +; SIMD128-NEXT: f32x4.add $push2=, $pop4, $pop1 |
| 119 | +; SIMD128-NEXT: f32x4.extract_lane $push3=, $pop2, 0 |
| 120 | +; SIMD128-NEXT: return $pop3 |
| 121 | + %res = tail call fast float @llvm.vector.reduce.fadd.f32.v4f32(float -0.0, <4 x float> %arg) |
| 122 | + ret float %res |
| 123 | +} |
| 124 | + |
| 125 | +declare i64 @llvm.vector.reduce.add.i64.v4i64(<2 x i64>) |
| 126 | +declare i32 @llvm.vector.reduce.add.i32.v4i32(<4 x i32>) |
| 127 | +declare i16 @llvm.vector.reduce.add.i16.v8i16(<8 x i16>) |
| 128 | +declare i8 @llvm.vector.reduce.add.i8.v16i8(<16 x i8>) |
| 129 | +declare double @llvm.vector.reduce.fadd.f64.v2f64(double, <2 x double>) |
| 130 | +declare float @llvm.vector.reduce.fadd.f32.v4f32(float, <4 x float>) |
0 commit comments