|
1 | 1 | ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s
|
2 | 2 | ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %}
|
3 | 3 |
|
4 |
| -; CHECK: OpMemoryModel Logical GLSL450 |
5 |
| -; CHECK-DAG: [[Z:%.*]] = OpConstant %[[#]] 0 |
6 |
| -; CHECK-DAG: [[X:%.*]] = OpConstant %[[#]] 1 |
| 4 | +; CHECK-DAG: [[glsl_450_ext:%.+]] = OpExtInstImport "GLSL.std.450" |
| 5 | +; CHECK-DAG: OpMemoryModel Logical GLSL450 |
| 6 | +; CHECK-DAG: [[u32_t:%.+]] = OpTypeInt 32 0 |
| 7 | +; CHECK-DAG: [[u32x2_t:%.+]] = OpTypeVector [[u32_t]] 2 |
| 8 | +; CHECK-DAG: [[u32x3_t:%.+]] = OpTypeVector [[u32_t]] 3 |
| 9 | +; CHECK-DAG: [[u32x4_t:%.+]] = OpTypeVector [[u32_t]] 4 |
| 10 | +; CHECK-DAG: [[const_0:%.*]] = OpConstant [[u32_t]] 0 |
| 11 | +; CHECK-DAG: [[const_0x2:%.*]] = OpConstantComposite [[u32x2_t]] [[const_0]] [[const_0]] |
| 12 | +; CHECK-DAG: [[const_1:%.*]] = OpConstant [[u32_t]] 1 |
| 13 | +; CHECK-DAG: [[const_32:%.*]] = OpConstant [[u32_t]] 32 |
| 14 | +; CHECK-DAG: [[const_32x2:%.*]] = OpConstantComposite [[u32x2_t]] [[const_32]] [[const_32]] |
| 15 | +; CHECK-DAG: [[const_neg1:%.*]] = OpConstant [[u32_t]] 4294967295 |
| 16 | +; CHECK-DAG: [[const_neg1x2:%.*]] = OpConstantComposite [[u32x2_t]] [[const_neg1]] [[const_neg1]] |
| 17 | +; CHECK-DAG: [[u16_t:%.+]] = OpTypeInt 16 0 |
| 18 | +; CHECK-DAG: [[u16x2_t:%.+]] = OpTypeVector [[u16_t]] 2 |
| 19 | +; CHECK-DAG: [[u16x3_t:%.+]] = OpTypeVector [[u16_t]] 3 |
| 20 | +; CHECK-DAG: [[u16x4_t:%.+]] = OpTypeVector [[u16_t]] 4 |
| 21 | +; CHECK-DAG: [[u64_t:%.+]] = OpTypeInt 64 0 |
| 22 | +; CHECK-DAG: [[u64x2_t:%.+]] = OpTypeVector [[u64_t]] 2 |
| 23 | +; CHECK-DAG: [[u64x3_t:%.+]] = OpTypeVector [[u64_t]] 3 |
| 24 | +; CHECK-DAG: [[u64x4_t:%.+]] = OpTypeVector [[u64_t]] 4 |
| 25 | +; CHECK-DAG: [[bool_t:%.+]] = OpTypeBool |
| 26 | +; CHECK-DAG: [[boolx2_t:%.+]] = OpTypeVector [[bool_t]] 2 |
7 | 27 |
|
| 28 | +; CHECK-LABEL: Begin function firstbituhigh_i32 |
8 | 29 | define noundef i32 @firstbituhigh_i32(i32 noundef %a) {
|
9 | 30 | entry:
|
10 |
| -; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FindUMsb %[[#]] |
| 31 | +; CHECK: [[a:%.+]] = OpFunctionParameter [[u32_t]] |
| 32 | +; CHECK: [[ret:%.+]] = OpExtInst [[u32_t]] [[glsl_450_ext]] FindUMsb [[a]] |
| 33 | +; CHECK: OpReturnValue [[ret]] |
11 | 34 | %elt.firstbituhigh = call i32 @llvm.spv.firstbituhigh.i32(i32 %a)
|
12 | 35 | ret i32 %elt.firstbituhigh
|
13 | 36 | }
|
14 | 37 |
|
15 |
| -define noundef <2 x i32> @firstbituhigh_2xi32(<2 x i32> noundef %a) { |
| 38 | +; CHECK-LABEL: Begin function firstbituhigh_v2xi32 |
| 39 | +define noundef <2 x i32> @firstbituhigh_v2xi32(<2 x i32> noundef %a) { |
16 | 40 | entry:
|
17 |
| -; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FindUMsb %[[#]] |
| 41 | +; CHECK: [[a:%.+]] = OpFunctionParameter [[u32x2_t]] |
| 42 | +; CHECK: [[ret:%.+]] = OpExtInst [[u32x2_t]] [[glsl_450_ext]] FindUMsb [[a]] |
| 43 | +; CHECK: OpReturnValue [[ret]] |
18 | 44 | %elt.firstbituhigh = call <2 x i32> @llvm.spv.firstbituhigh.v2i32(<2 x i32> %a)
|
19 | 45 | ret <2 x i32> %elt.firstbituhigh
|
20 | 46 | }
|
21 | 47 |
|
| 48 | +; CHECK-LABEL: Begin function firstbituhigh_v3xi32 |
| 49 | +define noundef <3 x i32> @firstbituhigh_v3xi32(<3 x i32> noundef %a) { |
| 50 | +entry: |
| 51 | +; CHECK: [[a:%.+]] = OpFunctionParameter [[u32x3_t]] |
| 52 | +; CHECK: [[ret:%.+]] = OpExtInst [[u32x3_t]] [[glsl_450_ext]] FindUMsb [[a]] |
| 53 | +; CHECK: OpReturnValue [[ret]] |
| 54 | + %elt.firstbituhigh = call <3 x i32> @llvm.spv.firstbituhigh.v3i32(<3 x i32> %a) |
| 55 | + ret <3 x i32> %elt.firstbituhigh |
| 56 | +} |
| 57 | + |
| 58 | +; CHECK-LABEL: Begin function firstbituhigh_v4xi32 |
| 59 | +define noundef <4 x i32> @firstbituhigh_v4xi32(<4 x i32> noundef %a) { |
| 60 | +entry: |
| 61 | +; CHECK: [[a:%.+]] = OpFunctionParameter [[u32x4_t]] |
| 62 | +; CHECK: [[ret:%.+]] = OpExtInst [[u32x4_t]] [[glsl_450_ext]] FindUMsb [[a]] |
| 63 | +; CHECK: OpReturnValue [[ret]] |
| 64 | + %elt.firstbituhigh = call <4 x i32> @llvm.spv.firstbituhigh.v4i32(<4 x i32> %a) |
| 65 | + ret <4 x i32> %elt.firstbituhigh |
| 66 | +} |
| 67 | + |
| 68 | +; CHECK-LABEL: Begin function firstbituhigh_i16 |
22 | 69 | define noundef i32 @firstbituhigh_i16(i16 noundef %a) {
|
23 | 70 | entry:
|
24 |
| -; CHECK: [[A:%.*]] = OpUConvert %[[#]] |
25 |
| -; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FindUMsb [[A]] |
| 71 | +; CHECK: [[a16:%.+]] = OpFunctionParameter [[u16_t]] |
| 72 | +; CHECK: [[a32:%.+]] = OpUConvert [[u32_t]] [[a16]] |
| 73 | +; CHECK: [[ret:%.+]] = OpExtInst [[u32_t]] [[glsl_450_ext]] FindUMsb [[a32]] |
| 74 | +; CHECK: OpReturnValue [[ret]] |
26 | 75 | %elt.firstbituhigh = call i32 @llvm.spv.firstbituhigh.i16(i16 %a)
|
27 | 76 | ret i32 %elt.firstbituhigh
|
28 | 77 | }
|
29 | 78 |
|
30 |
| -define noundef <2 x i32> @firstbituhigh_v2i16(<2 x i16> noundef %a) { |
| 79 | +; CHECK-LABEL: Begin function firstbituhigh_v2xi16 |
| 80 | +define noundef <2 x i32> @firstbituhigh_v2xi16(<2 x i16> noundef %a) { |
31 | 81 | entry:
|
32 |
| -; CHECK: [[A:%.*]] = OpUConvert %[[#]] |
33 |
| -; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FindUMsb [[A]] |
| 82 | +; CHECK: [[a16:%.+]] = OpFunctionParameter [[u16x2_t]] |
| 83 | +; CHECK: [[a32:%.+]] = OpUConvert [[u32x2_t]] [[a16]] |
| 84 | +; CHECK: [[ret:%.+]] = OpExtInst [[u32x2_t]] [[glsl_450_ext]] FindUMsb [[a32]] |
| 85 | +; CHECK: OpReturnValue [[ret]] |
34 | 86 | %elt.firstbituhigh = call <2 x i32> @llvm.spv.firstbituhigh.v2i16(<2 x i16> %a)
|
35 | 87 | ret <2 x i32> %elt.firstbituhigh
|
36 | 88 | }
|
37 | 89 |
|
| 90 | +; CHECK-LABEL: Begin function firstbituhigh_v3xi16 |
| 91 | +define noundef <3 x i32> @firstbituhigh_v3xi16(<3 x i16> noundef %a) { |
| 92 | +entry: |
| 93 | +; CHECK: [[a16:%.+]] = OpFunctionParameter [[u16x3_t]] |
| 94 | +; CHECK: [[a32:%.+]] = OpUConvert [[u32x3_t]] [[a16]] |
| 95 | +; CHECK: [[ret:%.+]] = OpExtInst [[u32x3_t]] [[glsl_450_ext]] FindUMsb [[a32]] |
| 96 | +; CHECK: OpReturnValue [[ret]] |
| 97 | + %elt.firstbituhigh = call <3 x i32> @llvm.spv.firstbituhigh.v3i16(<3 x i16> %a) |
| 98 | + ret <3 x i32> %elt.firstbituhigh |
| 99 | +} |
| 100 | + |
| 101 | +; CHECK-LABEL: Begin function firstbituhigh_v4xi16 |
| 102 | +define noundef <4 x i32> @firstbituhigh_v4xi16(<4 x i16> noundef %a) { |
| 103 | +entry: |
| 104 | +; CHECK: [[a16:%.+]] = OpFunctionParameter [[u16x4_t]] |
| 105 | +; CHECK: [[a32:%.+]] = OpUConvert [[u32x4_t]] [[a16]] |
| 106 | +; CHECK: [[ret:%.+]] = OpExtInst [[u32x4_t]] [[glsl_450_ext]] FindUMsb [[a32]] |
| 107 | +; CHECK: OpReturnValue [[ret]] |
| 108 | + %elt.firstbituhigh = call <4 x i32> @llvm.spv.firstbituhigh.v4i16(<4 x i16> %a) |
| 109 | + ret <4 x i32> %elt.firstbituhigh |
| 110 | +} |
| 111 | + |
| 112 | +; CHECK-LABEL: Begin function firstbituhigh_i64 |
38 | 113 | define noundef i32 @firstbituhigh_i64(i64 noundef %a) {
|
39 | 114 | entry:
|
40 |
| -; CHECK: [[O:%.*]] = OpBitcast %[[#]] %[[#]] |
41 |
| -; CHECK: [[N:%.*]] = OpExtInst %[[#]] %[[#]] FindUMsb [[O]] |
42 |
| -; CHECK: [[M:%.*]] = OpVectorExtractDynamic %[[#]] [[N]] [[Z]] |
43 |
| -; CHECK: [[L:%.*]] = OpVectorExtractDynamic %[[#]] [[N]] [[X]] |
44 |
| -; CHECK: [[I:%.*]] = OpIEqual %[[#]] [[M]] %[[#]] |
45 |
| -; CHECK: [[H:%.*]] = OpSelect %[[#]] [[I]] [[L]] [[M]] |
46 |
| -; CHECK: [[C:%.*]] = OpSelect %[[#]] [[I]] %[[#]] %[[#]] |
47 |
| -; CHECK: [[B:%.*]] = OpIAdd %[[#]] [[C]] [[H]] |
| 115 | +; CHECK: [[a64:%.+]] = OpFunctionParameter [[u64_t]] |
| 116 | +; CHECK: [[a32x2:%.+]] = OpBitcast [[u32x2_t]] [[a64]] |
| 117 | +; CHECK: [[lsb_bits:%.+]] = OpExtInst [[u32x2_t]] [[glsl_450_ext]] FindUMsb [[a32x2]] |
| 118 | +; CHECK: [[high_bits:%.+]] = OpVectorExtractDynamic [[u32_t]] [[lsb_bits]] [[const_0]] |
| 119 | +; CHECK: [[low_bits:%.+]] = OpVectorExtractDynamic [[u32_t]] [[lsb_bits]] [[const_1]] |
| 120 | +; CHECK: [[should_use_low:%.+]] = OpIEqual [[bool_t]] [[high_bits]] [[const_neg1]] |
| 121 | +; CHECK: [[ans_bits:%.+]] = OpSelect [[u32_t]] [[should_use_low]] [[low_bits]] [[high_bits]] |
| 122 | +; CHECK: [[ans_offset:%.+]] = OpSelect [[u32_t]] [[should_use_low]] [[const_0]] [[const_32]] |
| 123 | +; CHECK: [[ret:%.+]] = OpIAdd [[u32_t]] [[ans_offset]] [[ans_bits]] |
| 124 | +; CHECK: OpReturnValue [[ret]] |
48 | 125 | %elt.firstbituhigh = call i32 @llvm.spv.firstbituhigh.i64(i64 %a)
|
49 | 126 | ret i32 %elt.firstbituhigh
|
50 | 127 | }
|
51 | 128 |
|
52 |
| -define noundef <2 x i32> @firstbituhigh_v2i64(<2 x i64> noundef %a) { |
| 129 | +; CHECK-LABEL: Begin function firstbituhigh_v2xi64 |
| 130 | +define noundef <2 x i32> @firstbituhigh_v2xi64(<2 x i64> noundef %a) { |
53 | 131 | entry:
|
54 |
| -; CHECK: [[O:%.*]] = OpBitcast %[[#]] %[[#]] |
55 |
| -; CHECK: [[N:%.*]] = OpExtInst %[[#]] %[[#]] FindUMsb [[O]] |
56 |
| -; CHECK: [[M:%.*]] = OpVectorShuffle %[[#]] [[N]] [[N]] 0 |
57 |
| -; CHECK: [[L:%.*]] = OpVectorShuffle %[[#]] [[N]] [[N]] 1 |
58 |
| -; CHECK: [[I:%.*]] = OpIEqual %[[#]] [[M]] %[[#]] |
59 |
| -; CHECK: [[H:%.*]] = OpSelect %[[#]] [[I]] [[L]] [[M]] |
60 |
| -; CHECK: [[C:%.*]] = OpSelect %[[#]] [[I]] %[[#]] %[[#]] |
61 |
| -; CHECK: [[B:%.*]] = OpIAdd %[[#]] [[C]] [[H]] |
62 |
| -; CHECK: OpReturnValue [[B]] |
| 132 | +; CHECK: [[a64x2:%.+]] = OpFunctionParameter [[u64x2_t]] |
| 133 | +; CHECK: [[a32x4:%.+]] = OpBitcast [[u32x4_t]] [[a64x2]] |
| 134 | +; CHECK: [[lsb_bits:%.+]] = OpExtInst [[u32x4_t]] [[glsl_450_ext]] FindUMsb [[a32x4]] |
| 135 | +; CHECK: [[high_bits:%.+]] = OpVectorShuffle [[u32x2_t]] [[lsb_bits]] [[lsb_bits]] 0 2 |
| 136 | +; CHECK: [[low_bits:%.+]] = OpVectorShuffle [[u32x2_t]] [[lsb_bits]] [[lsb_bits]] 1 3 |
| 137 | +; CHECK: [[should_use_low:%.+]] = OpIEqual [[boolx2_t]] [[high_bits]] [[const_neg1x2]] |
| 138 | +; CHECK: [[ans_bits:%.+]] = OpSelect [[u32x2_t]] [[should_use_low]] [[low_bits]] [[high_bits]] |
| 139 | +; CHECK: [[ans_offset:%.+]] = OpSelect [[u32x2_t]] [[should_use_low]] [[const_0x2]] [[const_32x2]] |
| 140 | +; CHECK: [[ret:%.+]] = OpIAdd [[u32x2_t]] [[ans_offset]] [[ans_bits]] |
| 141 | +; CHECK: OpReturnValue [[ret]] |
63 | 142 | %elt.firstbituhigh = call <2 x i32> @llvm.spv.firstbituhigh.v2i64(<2 x i64> %a)
|
64 | 143 | ret <2 x i32> %elt.firstbituhigh
|
65 | 144 | }
|
66 | 145 |
|
| 146 | +; CHECK-LABEL: Begin function firstbituhigh_v3xi64 |
| 147 | +define noundef <3 x i32> @firstbituhigh_v3xi64(<3 x i64> noundef %a) { |
| 148 | +entry: |
| 149 | +; Split the i64x3 into i64, i64x2 |
| 150 | +; CHECK: [[a:%.+]] = OpFunctionParameter [[u64x3_t]] |
| 151 | +; CHECK: [[left:%.+]] = OpVectorExtractDynamic [[u64_t]] [[a]] [[const_0]] |
| 152 | +; CHECK: [[right:%.+]] = OpVectorShuffle [[u64x2_t]] [[a]] [[a]] 1 2 |
| 153 | + |
| 154 | +; Do firstbituhigh on i64, i64x2 |
| 155 | +; CHECK: [[left_cast:%.+]] = OpBitcast [[u32x2_t]] [[left]] |
| 156 | +; CHECK: [[left_lsb_bits:%.+]] = OpExtInst [[u32x2_t]] [[glsl_450_ext]] FindUMsb [[left_cast]] |
| 157 | +; CHECK: [[left_high_bits:%.+]] = OpVectorExtractDynamic [[u32_t]] [[left_lsb_bits]] [[const_0]] |
| 158 | +; CHECK: [[left_low_bits:%.+]] = OpVectorExtractDynamic [[u32_t]] [[left_lsb_bits]] [[const_1]] |
| 159 | +; CHECK: [[left_should_use_low:%.+]] = OpIEqual [[bool_t]] [[left_high_bits]] [[const_neg1]] |
| 160 | +; CHECK: [[left_ans_bits:%.+]] = OpSelect [[u32_t]] [[left_should_use_low]] [[left_low_bits]] [[left_high_bits]] |
| 161 | +; CHECK: [[left_ans_offset:%.+]] = OpSelect [[u32_t]] [[left_should_use_low]] [[const_0]] [[const_32]] |
| 162 | +; CHECK: [[left_res:%.+]] = OpIAdd [[u32_t]] [[left_ans_offset]] [[left_ans_bits]] |
| 163 | + |
| 164 | +; CHECK: [[right_cast:%.+]] = OpBitcast [[u32x4_t]] [[right]] |
| 165 | +; CHECK: [[right_lsb_bits:%.+]] = OpExtInst [[u32x4_t]] [[glsl_450_ext]] FindUMsb [[right_cast]] |
| 166 | +; CHECK: [[right_high_bits:%.+]] = OpVectorShuffle [[u32x2_t]] [[right_lsb_bits]] [[right_lsb_bits]] 0 2 |
| 167 | +; CHECK: [[right_low_bits:%.+]] = OpVectorShuffle [[u32x2_t]] [[right_lsb_bits]] [[right_lsb_bits]] 1 3 |
| 168 | +; CHECK: [[right_should_use_low:%.+]] = OpIEqual [[boolx2_t]] [[right_high_bits]] [[const_neg1x2]] |
| 169 | +; CHECK: [[right_ans_bits:%.+]] = OpSelect [[u32x2_t]] [[right_should_use_low]] [[right_low_bits]] [[right_high_bits]] |
| 170 | +; CHECK: [[right_ans_offset:%.+]] = OpSelect [[u32x2_t]] [[right_should_use_low]] [[const_0x2]] [[const_32x2]] |
| 171 | +; CHECK: [[right_res:%.+]] = OpIAdd [[u32x2_t]] [[right_ans_offset]] [[right_ans_bits]] |
| 172 | + |
| 173 | +; Merge the resulting i32, i32x2 into the final i32x3 and return it |
| 174 | +; CHECK: [[ret:%.+]] = OpCompositeConstruct [[u32x3_t]] [[left_res]] [[right_res]] |
| 175 | +; CHECK: OpReturnValue [[ret]] |
| 176 | + %elt.firstbituhigh = call <3 x i32> @llvm.spv.firstbituhigh.v3i64(<3 x i64> %a) |
| 177 | + ret <3 x i32> %elt.firstbituhigh |
| 178 | +} |
| 179 | + |
| 180 | +; CHECK-LABEL: Begin function firstbituhigh_v4xi64 |
| 181 | +define noundef <4 x i32> @firstbituhigh_v4xi64(<4 x i64> noundef %a) { |
| 182 | +entry: |
| 183 | +; Split the i64x4 into 2 i64x2 |
| 184 | +; CHECK: [[a:%.+]] = OpFunctionParameter [[u64x4_t]] |
| 185 | +; CHECK: [[left:%.+]] = OpVectorShuffle [[u64x2_t]] [[a]] [[a]] 0 1 |
| 186 | +; CHECK: [[right:%.+]] = OpVectorShuffle [[u64x2_t]] [[a]] [[a]] 2 3 |
| 187 | + |
| 188 | +; Do firstbithigh on the 2 i64x2 |
| 189 | +; CHECK: [[left_cast:%.+]] = OpBitcast [[u32x4_t]] [[left]] |
| 190 | +; CHECK: [[left_lsb_bits:%.+]] = OpExtInst [[u32x4_t]] [[glsl_450_ext]] FindUMsb [[left_cast]] |
| 191 | +; CHECK: [[left_high_bits:%.+]] = OpVectorShuffle [[u32x2_t]] [[left_lsb_bits]] [[left_lsb_bits]] 0 2 |
| 192 | +; CHECK: [[left_low_bits:%.+]] = OpVectorShuffle [[u32x2_t]] [[left_lsb_bits]] [[left_lsb_bits]] 1 3 |
| 193 | +; CHECK: [[left_should_use_low:%.+]] = OpIEqual [[boolx2_t]] [[left_high_bits]] [[const_neg1x2]] |
| 194 | +; CHECK: [[left_ans_bits:%.+]] = OpSelect [[u32x2_t]] [[left_should_use_low]] [[left_low_bits]] [[left_high_bits]] |
| 195 | +; CHECK: [[left_ans_offset:%.+]] = OpSelect [[u32x2_t]] [[left_should_use_low]] [[const_0x2]] [[const_32x2]] |
| 196 | +; CHECK: [[left_res:%.+]] = OpIAdd [[u32x2_t]] [[left_ans_offset]] [[left_ans_bits]] |
| 197 | + |
| 198 | +; CHECK: [[right_cast:%.+]] = OpBitcast [[u32x4_t]] [[right]] |
| 199 | +; CHECK: [[right_lsb_bits:%.+]] = OpExtInst [[u32x4_t]] [[glsl_450_ext]] FindUMsb [[right_cast]] |
| 200 | +; CHECK: [[right_high_bits:%.+]] = OpVectorShuffle [[u32x2_t]] [[right_lsb_bits]] [[right_lsb_bits]] 0 2 |
| 201 | +; CHECK: [[right_low_bits:%.+]] = OpVectorShuffle [[u32x2_t]] [[right_lsb_bits]] [[right_lsb_bits]] 1 3 |
| 202 | +; CHECK: [[right_should_use_low:%.+]] = OpIEqual [[boolx2_t]] [[right_high_bits]] [[const_neg1x2]] |
| 203 | +; CHECK: [[right_ans_bits:%.+]] = OpSelect [[u32x2_t]] [[right_should_use_low]] [[right_low_bits]] [[right_high_bits]] |
| 204 | +; CHECK: [[right_ans_offset:%.+]] = OpSelect [[u32x2_t]] [[right_should_use_low]] [[const_0x2]] [[const_32x2]] |
| 205 | +; CHECK: [[right_res:%.+]] = OpIAdd [[u32x2_t]] [[right_ans_offset]] [[right_ans_bits]] |
| 206 | + |
| 207 | +; Merge the resulting 2 i32x2 into the final i32x4 and return it |
| 208 | +; CHECK: [[ret:%.+]] = OpCompositeConstruct [[u32x4_t]] [[left_res]] [[right_res]] |
| 209 | +; CHECK: OpReturnValue [[ret]] |
| 210 | + %elt.firstbituhigh = call <4 x i32> @llvm.spv.firstbituhigh.v4i64(<4 x i64> %a) |
| 211 | + ret <4 x i32> %elt.firstbituhigh |
| 212 | +} |
| 213 | + |
| 214 | +; CHECK-LABEL: Begin function firstbitshigh_i32 |
67 | 215 | define noundef i32 @firstbitshigh_i32(i32 noundef %a) {
|
68 | 216 | entry:
|
69 |
| -; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FindSMsb %[[#]] |
| 217 | +; CHECK: [[a:%.+]] = OpFunctionParameter [[u32_t]] |
| 218 | +; CHECK: [[ret:%.+]] = OpExtInst [[u32_t]] [[glsl_450_ext]] FindSMsb [[a]] |
| 219 | +; CHECK: OpReturnValue [[ret]] |
70 | 220 | %elt.firstbitshigh = call i32 @llvm.spv.firstbitshigh.i32(i32 %a)
|
71 | 221 | ret i32 %elt.firstbitshigh
|
72 | 222 | }
|
73 | 223 |
|
| 224 | +; CHECK-LABEL: Begin function firstbitshigh_i16 |
74 | 225 | define noundef i32 @firstbitshigh_i16(i16 noundef %a) {
|
75 | 226 | entry:
|
76 |
| -; CHECK: [[A:%.*]] = OpSConvert %[[#]] |
77 |
| -; CHECK: %[[#]] = OpExtInst %[[#]] %[[#]] FindSMsb %[[#]] |
| 227 | +; CHECK: [[a16:%.+]] = OpFunctionParameter [[u16_t]] |
| 228 | +; CHECK: [[a32:%.+]] = OpSConvert [[u32_t]] [[a16]] |
| 229 | +; CHECK: [[ret:%.+]] = OpExtInst [[u32_t]] [[glsl_450_ext]] FindSMsb [[a32]] |
| 230 | +; CHECK: OpReturnValue [[ret]] |
78 | 231 | %elt.firstbitshigh = call i32 @llvm.spv.firstbitshigh.i16(i16 %a)
|
79 | 232 | ret i32 %elt.firstbitshigh
|
80 | 233 | }
|
81 | 234 |
|
| 235 | +; CHECK-LABEL: Begin function firstbitshigh_i64 |
82 | 236 | define noundef i32 @firstbitshigh_i64(i64 noundef %a) {
|
83 | 237 | entry:
|
84 |
| -; CHECK: [[O:%.*]] = OpBitcast %[[#]] %[[#]] |
85 |
| -; CHECK: [[N:%.*]] = OpExtInst %[[#]] %[[#]] FindSMsb [[O]] |
86 |
| -; CHECK: [[M:%.*]] = OpVectorExtractDynamic %[[#]] [[N]] [[Z]] |
87 |
| -; CHECK: [[L:%.*]] = OpVectorExtractDynamic %[[#]] [[N]] [[X]] |
88 |
| -; CHECK: [[I:%.*]] = OpIEqual %[[#]] [[M]] %[[#]] |
89 |
| -; CHECK: [[H:%.*]] = OpSelect %[[#]] [[I]] [[L]] [[M]] |
90 |
| -; CHECK: [[C:%.*]] = OpSelect %[[#]] [[I]] %[[#]] %[[#]] |
91 |
| -; CHECK: [[B:%.*]] = OpIAdd %[[#]] [[C]] [[H]] |
| 238 | +; CHECK: [[a64:%.+]] = OpFunctionParameter [[u64_t]] |
| 239 | +; CHECK: [[a32x2:%.+]] = OpBitcast [[u32x2_t]] [[a64]] |
| 240 | +; CHECK: [[lsb_bits:%.+]] = OpExtInst [[u32x2_t]] [[glsl_450_ext]] FindSMsb [[a32x2]] |
| 241 | +; CHECK: [[high_bits:%.+]] = OpVectorExtractDynamic [[u32_t]] [[lsb_bits]] [[const_0]] |
| 242 | +; CHECK: [[low_bits:%.+]] = OpVectorExtractDynamic [[u32_t]] [[lsb_bits]] [[const_1]] |
| 243 | +; CHECK: [[should_use_low:%.+]] = OpIEqual [[bool_t]] [[high_bits]] [[const_neg1]] |
| 244 | +; CHECK: [[ans_bits:%.+]] = OpSelect [[u32_t]] [[should_use_low]] [[low_bits]] [[high_bits]] |
| 245 | +; CHECK: [[ans_offset:%.+]] = OpSelect [[u32_t]] [[should_use_low]] [[const_0]] [[const_32]] |
| 246 | +; CHECK: [[ret:%.+]] = OpIAdd [[u32_t]] [[ans_offset]] [[ans_bits]] |
| 247 | +; CHECK: OpReturnValue [[ret]] |
92 | 248 | %elt.firstbitshigh = call i32 @llvm.spv.firstbitshigh.i64(i64 %a)
|
93 | 249 | ret i32 %elt.firstbitshigh
|
94 | 250 | }
|
|
0 commit comments