1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -verify-machineinstrs -mattr=+simd128 | FileCheck %s
; Test that a vector trunc correctly optimizes and lowers to narrow instructions
target triple = "wasm32-unknown-unknown"
define <16 x i8> @trunc16i64_16i8(<16 x i64> %a) {
; CHECK-LABEL: trunc16i64_16i8:
; CHECK: .functype trunc16i64_16i8 (v128, v128, v128, v128, v128, v128, v128, v128) -> (v128)
; CHECK-NEXT: .local v128
; CHECK-NEXT: # %bb.0: # %entry
; CHECK-NEXT: local.get 0
; CHECK-NEXT: v128.const 255, 255
; CHECK-NEXT: local.tee 8
; CHECK-NEXT: v128.and
; CHECK-NEXT: local.get 1
; CHECK-NEXT: local.get 8
; CHECK-NEXT: v128.and
; CHECK-NEXT: i16x8.narrow_i32x4_u
; CHECK-NEXT: local.get 2
; CHECK-NEXT: local.get 8
; CHECK-NEXT: v128.and
; CHECK-NEXT: local.get 3
; CHECK-NEXT: local.get 8
; CHECK-NEXT: v128.and
; CHECK-NEXT: i16x8.narrow_i32x4_u
; CHECK-NEXT: i16x8.narrow_i32x4_u
; CHECK-NEXT: local.get 4
; CHECK-NEXT: local.get 8
; CHECK-NEXT: v128.and
; CHECK-NEXT: local.get 5
; CHECK-NEXT: local.get 8
; CHECK-NEXT: v128.and
; CHECK-NEXT: i16x8.narrow_i32x4_u
; CHECK-NEXT: local.get 6
; CHECK-NEXT: local.get 8
; CHECK-NEXT: v128.and
; CHECK-NEXT: local.get 7
; CHECK-NEXT: local.get 8
; CHECK-NEXT: v128.and
; CHECK-NEXT: i16x8.narrow_i32x4_u
; CHECK-NEXT: i16x8.narrow_i32x4_u
; CHECK-NEXT: i8x16.narrow_i16x8_u
; CHECK-NEXT: # fallthrough-return
entry:
%0 = trunc <16 x i64> %a to <16 x i8>
ret <16 x i8> %0
}
define <16 x i8> @trunc16i32_16i8(<16 x i32> %a) {
; CHECK-LABEL: trunc16i32_16i8:
; CHECK: .functype trunc16i32_16i8 (v128, v128, v128, v128) -> (v128)
; CHECK-NEXT: .local v128
; CHECK-NEXT: # %bb.0: # %entry
; CHECK-NEXT: local.get 0
; CHECK-NEXT: v128.const 255, 255, 255, 255
; CHECK-NEXT: local.tee 4
; CHECK-NEXT: v128.and
; CHECK-NEXT: local.get 1
; CHECK-NEXT: local.get 4
; CHECK-NEXT: v128.and
; CHECK-NEXT: i16x8.narrow_i32x4_u
; CHECK-NEXT: local.get 2
; CHECK-NEXT: local.get 4
; CHECK-NEXT: v128.and
; CHECK-NEXT: local.get 3
; CHECK-NEXT: local.get 4
; CHECK-NEXT: v128.and
; CHECK-NEXT: i16x8.narrow_i32x4_u
; CHECK-NEXT: i8x16.narrow_i16x8_u
; CHECK-NEXT: # fallthrough-return
entry:
%0 = trunc <16 x i32> %a to <16 x i8>
ret <16 x i8> %0
}
define <16 x i8> @trunc16i16_16i8(<16 x i16> %a) {
; CHECK-LABEL: trunc16i16_16i8:
; CHECK: .functype trunc16i16_16i8 (v128, v128) -> (v128)
; CHECK-NEXT: .local v128
; CHECK-NEXT: # %bb.0: # %entry
; CHECK-NEXT: local.get 0
; CHECK-NEXT: v128.const 255, 255, 255, 255, 255, 255, 255, 255
; CHECK-NEXT: local.tee 2
; CHECK-NEXT: v128.and
; CHECK-NEXT: local.get 1
; CHECK-NEXT: local.get 2
; CHECK-NEXT: v128.and
; CHECK-NEXT: i8x16.narrow_i16x8_u
; CHECK-NEXT: # fallthrough-return
entry:
%0 = trunc <16 x i16> %a to <16 x i8>
ret <16 x i8> %0
}
define <8 x i16> @trunc8i64_8i16(<8 x i64> %a) {
; CHECK-LABEL: trunc8i64_8i16:
; CHECK: .functype trunc8i64_8i16 (v128, v128, v128, v128) -> (v128)
; CHECK-NEXT: .local v128
; CHECK-NEXT: # %bb.0: # %entry
; CHECK-NEXT: local.get 0
; CHECK-NEXT: v128.const 65535, 65535
; CHECK-NEXT: local.tee 4
; CHECK-NEXT: v128.and
; CHECK-NEXT: local.get 1
; CHECK-NEXT: local.get 4
; CHECK-NEXT: v128.and
; CHECK-NEXT: i16x8.narrow_i32x4_u
; CHECK-NEXT: local.get 2
; CHECK-NEXT: local.get 4
; CHECK-NEXT: v128.and
; CHECK-NEXT: local.get 3
; CHECK-NEXT: local.get 4
; CHECK-NEXT: v128.and
; CHECK-NEXT: i16x8.narrow_i32x4_u
; CHECK-NEXT: i16x8.narrow_i32x4_u
; CHECK-NEXT: # fallthrough-return
entry:
%0 = trunc <8 x i64> %a to <8 x i16>
ret <8 x i16> %0
}
define <8 x i16> @trunc8i32_8i16(<8 x i32> %a) {
; CHECK-LABEL: trunc8i32_8i16:
; CHECK: .functype trunc8i32_8i16 (v128, v128) -> (v128)
; CHECK-NEXT: .local v128
; CHECK-NEXT: # %bb.0: # %entry
; CHECK-NEXT: local.get 0
; CHECK-NEXT: v128.const 65535, 65535, 65535, 65535
; CHECK-NEXT: local.tee 2
; CHECK-NEXT: v128.and
; CHECK-NEXT: local.get 1
; CHECK-NEXT: local.get 2
; CHECK-NEXT: v128.and
; CHECK-NEXT: i16x8.narrow_i32x4_u
; CHECK-NEXT: # fallthrough-return
entry:
%0 = trunc <8 x i32> %a to <8 x i16>
ret <8 x i16> %0
}
|