Thomas Lively | 079816e | 2019-01-30 02:23:29 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+unimplemented-simd128 | FileCheck %s |
| 2 | |
| 3 | ; Test that the logic to choose between v128.const vector |
| 4 | ; initialization and splat vector initialization and to optimize the |
| 5 | ; choice of splat value works correctly. |
| 6 | |
| 7 | target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" |
| 8 | target triple = "wasm32-unknown-unknown" |
| 9 | |
| 10 | ; CHECK-LABEL: same_const_one_replaced_i8x16: |
| 11 | ; CHECK-NEXT: .functype same_const_one_replaced_i8x16 (i32) -> (v128) |
| 12 | ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 42 |
| 13 | ; CHECK-NEXT: i16x8.splat $push[[L1:[0-9]+]]=, $pop[[L0]] |
| 14 | ; CHECK-NEXT: i16x8.replace_lane $push[[L2:[0-9]+]]=, $pop[[L1]], 5, $0 |
| 15 | ; CHECK-NEXT: return $pop[[L2]] |
| 16 | define <8 x i16> @same_const_one_replaced_i8x16(i16 %x) { |
| 17 | %v = insertelement |
| 18 | <8 x i16> <i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42>, |
| 19 | i16 %x, |
| 20 | i32 5 |
| 21 | ret <8 x i16> %v |
| 22 | } |
| 23 | |
| 24 | ; CHECK-LABEL: different_const_one_replaced_i8x16: |
| 25 | ; CHECK-NEXT: .functype different_const_one_replaced_i8x16 (i32) -> (v128) |
Thomas Lively | 9a48438 | 2019-01-31 23:22:39 +0000 | [diff] [blame] | 26 | ; CHECK-NEXT: v128.const $push[[L0:[0-9]+]]=, 1, -2, 3, -4, 5, 0, 7, -8 |
Thomas Lively | 079816e | 2019-01-30 02:23:29 +0000 | [diff] [blame] | 27 | ; CHECK-NEXT: i16x8.replace_lane $push[[L1:[0-9]+]]=, $pop[[L0]], 5, $0 |
| 28 | ; CHECK-NEXT: return $pop[[L1]] |
| 29 | define <8 x i16> @different_const_one_replaced_i8x16(i16 %x) { |
| 30 | %v = insertelement |
Thomas Lively | 9a48438 | 2019-01-31 23:22:39 +0000 | [diff] [blame] | 31 | <8 x i16> <i16 1, i16 -2, i16 3, i16 -4, i16 5, i16 -6, i16 7, i16 -8>, |
Thomas Lively | 079816e | 2019-01-30 02:23:29 +0000 | [diff] [blame] | 32 | i16 %x, |
| 33 | i32 5 |
| 34 | ret <8 x i16> %v |
| 35 | } |
| 36 | |
| 37 | ; CHECK-LABEL: same_const_one_replaced_f32x4: |
| 38 | ; CHECK-NEXT: .functype same_const_one_replaced_f32x4 (f32) -> (v128) |
| 39 | ; CHECK-NEXT: f32.const $push[[L0:[0-9]+]]=, 0x1.5p5 |
| 40 | ; CHECK-NEXT: f32x4.splat $push[[L1:[0-9]+]]=, $pop[[L0]] |
| 41 | ; CHECK-NEXT: f32x4.replace_lane $push[[L2:[0-9]+]]=, $pop[[L1]], 2, $0 |
| 42 | ; CHECK-NEXT: return $pop[[L2]] |
| 43 | define <4 x float> @same_const_one_replaced_f32x4(float %x) { |
| 44 | %v = insertelement |
| 45 | <4 x float> <float 42., float 42., float 42., float 42.>, |
| 46 | float %x, |
| 47 | i32 2 |
| 48 | ret <4 x float> %v |
| 49 | } |
| 50 | |
| 51 | ; CHECK-LABEL: different_const_one_replaced_f32x4: |
| 52 | ; CHECK-NEXT: .functype different_const_one_replaced_f32x4 (f32) -> (v128) |
| 53 | ; CHECK-NEXT: v128.const $push[[L0:[0-9]+]]=, 0x1p0, 0x1p1, 0x0p0, 0x1p2 |
| 54 | ; CHECK-NEXT: f32x4.replace_lane $push[[L1:[0-9]+]]=, $pop[[L0]], 2, $0 |
| 55 | ; CHECK-NEXT: return $pop[[L1]] |
| 56 | define <4 x float> @different_const_one_replaced_f32x4(float %x) { |
| 57 | %v = insertelement |
| 58 | <4 x float> <float 1., float 2., float 3., float 4.>, |
| 59 | float %x, |
| 60 | i32 2 |
| 61 | ret <4 x float> %v |
| 62 | } |
| 63 | |
| 64 | ; CHECK-LABEL: splat_common_const_i32x4: |
| 65 | ; CHECK-NEXT: .functype splat_common_const_i32x4 () -> (v128) |
| 66 | ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 3 |
| 67 | ; CHECK-NEXT: i32x4.splat $push[[L1:[0-9]+]]=, $pop[[L0]] |
| 68 | ; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 1 |
| 69 | ; CHECK-NEXT: i32x4.replace_lane $push[[L3:[0-9]+]]=, $pop[[L1]], 3, $pop[[L2]] |
| 70 | ; CHECK-NEXT: return $pop[[L3]] |
| 71 | define <4 x i32> @splat_common_const_i32x4() { |
| 72 | ret <4 x i32> <i32 undef, i32 3, i32 3, i32 1> |
| 73 | } |
| 74 | |
| 75 | ; CHECK-LABEL: splat_common_arg_i16x8: |
| 76 | ; CHECK-NEXT: .functype splat_common_arg_i16x8 (i32, i32, i32) -> (v128) |
| 77 | ; CHECK-NEXT: i16x8.splat $push[[L0:[0-9]+]]=, $2 |
| 78 | ; CHECK-NEXT: i16x8.replace_lane $push[[L1:[0-9]+]]=, $pop[[L0]], 0, $1 |
| 79 | ; CHECK-NEXT: i16x8.replace_lane $push[[L2:[0-9]+]]=, $pop[[L1]], 2, $0 |
| 80 | ; CHECK-NEXT: i16x8.replace_lane $push[[L3:[0-9]+]]=, $pop[[L2]], 4, $1 |
| 81 | ; CHECK-NEXT: i16x8.replace_lane $push[[L4:[0-9]+]]=, $pop[[L3]], 7, $1 |
| 82 | ; CHECK-NEXT: return $pop[[L4]] |
| 83 | define <8 x i16> @splat_common_arg_i16x8(i16 %a, i16 %b, i16 %c) { |
| 84 | %v0 = insertelement <8 x i16> undef, i16 %b, i32 0 |
| 85 | %v1 = insertelement <8 x i16> %v0, i16 %c, i32 1 |
| 86 | %v2 = insertelement <8 x i16> %v1, i16 %a, i32 2 |
| 87 | %v3 = insertelement <8 x i16> %v2, i16 %c, i32 3 |
| 88 | %v4 = insertelement <8 x i16> %v3, i16 %b, i32 4 |
| 89 | %v5 = insertelement <8 x i16> %v4, i16 %c, i32 5 |
| 90 | %v6 = insertelement <8 x i16> %v5, i16 %c, i32 6 |
| 91 | %v7 = insertelement <8 x i16> %v6, i16 %b, i32 7 |
| 92 | ret <8 x i16> %v7 |
| 93 | } |
| 94 | |
| 95 | ; CHECK-LABEL: undef_const_insert_f32x4: |
| 96 | ; CHECK-NEXT: .functype undef_const_insert_f32x4 () -> (v128) |
| 97 | ; CHECK-NEXT: f32.const $push[[L0:[0-9]+]]=, 0x1.5p5 |
| 98 | ; CHECK-NEXT: f32x4.splat $push[[L1:[0-9]+]]=, $pop[[L0]] |
| 99 | ; CHECK-NEXT: return $pop[[L1]] |
| 100 | define <4 x float> @undef_const_insert_f32x4() { |
| 101 | %v = insertelement <4 x float> undef, float 42., i32 1 |
| 102 | ret <4 x float> %v |
| 103 | } |
| 104 | |
| 105 | ; CHECK-LABEL: undef_arg_insert_i32x4: |
| 106 | ; CHECK-NEXT: .functype undef_arg_insert_i32x4 (i32) -> (v128) |
| 107 | ; CHECK-NEXT: i32x4.splat $push[[L0:[0-9]+]]=, $0 |
| 108 | ; CHECK-NEXT: return $pop[[L0]] |
| 109 | define <4 x i32> @undef_arg_insert_i32x4(i32 %x) { |
| 110 | %v = insertelement <4 x i32> undef, i32 %x, i32 3 |
| 111 | ret <4 x i32> %v |
| 112 | } |
| 113 | |
| 114 | ; CHECK-LABEL: all_undef_i8x16: |
| 115 | ; CHECK-NEXT: .functype all_undef_i8x16 () -> (v128) |
| 116 | ; CHECK-NEXT: return $0 |
| 117 | define <16 x i8> @all_undef_i8x16() { |
| 118 | %v = insertelement <16 x i8> undef, i8 undef, i32 4 |
| 119 | ret <16 x i8> %v |
| 120 | } |
| 121 | |
| 122 | ; CHECK-LABEL: all_undef_f64x2: |
| 123 | ; CHECK-NEXT: .functype all_undef_f64x2 () -> (v128) |
| 124 | ; CHECK-NEXT: return $0 |
| 125 | define <2 x double> @all_undef_f64x2() { |
| 126 | ret <2 x double> undef |
| 127 | } |