| 1 |
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ |
| 2 |
// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ |
| 3 |
// RUN: -fnative-int16-type -emit-llvm -O1 -o - | FileCheck %s -DTARGET=dx \ |
| 4 |
// RUN: --check-prefixes=CHECK,DXCHECK |
| 5 |
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ |
| 6 |
// RUN: spirv-unknown-vulkan-compute %s -fnative-half-type \ |
| 7 |
// RUN: -fnative-int16-type -emit-llvm -O1 -o - | FileCheck %s -DTARGET=spv |
| 8 |
|
| 9 |
#ifdef __HLSL_ENABLE_16_BIT |
| 10 |
// CHECK-LABEL: test_firstbithigh_ushort |
| 11 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}i32 @llvm.[[TARGET]].firstbituhigh.i16 |
| 12 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub i32 15, [[FBH]] |
| 13 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq i32 [[FBH]], -1 |
| 14 |
// DXCHECK-NEXT: select i1 %cmp.i, i32 -1, i32 [[SUB]] |
| 15 |
// CHECK-NEXT: ret i32 |
| 16 |
uint test_firstbithigh_ushort(uint16_t p0) { |
| 17 |
return firstbithigh(p0); |
| 18 |
} |
| 19 |
|
| 20 |
// CHECK-LABEL: test_firstbithigh_ushort2 |
| 21 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<2 x i32> @llvm.[[TARGET]].firstbituhigh.v2i16 |
| 22 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <2 x i32> splat (i32 15), [[FBH]] |
| 23 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <2 x i32> [[FBH]], splat (i32 -1) |
| 24 |
// DXCHECK-NEXT: select <2 x i1> %cmp.i, <2 x i32> splat (i32 -1), <2 x i32> [[SUB]] |
| 25 |
// CHECK-NEXT: ret <2 x i32> |
| 26 |
uint2 test_firstbithigh_ushort2(uint16_t2 p0) { |
| 27 |
return firstbithigh(p0); |
| 28 |
} |
| 29 |
|
| 30 |
// CHECK-LABEL: test_firstbithigh_ushort3 |
| 31 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<3 x i32> @llvm.[[TARGET]].firstbituhigh.v3i16 |
| 32 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <3 x i32> splat (i32 15), [[FBH]] |
| 33 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <3 x i32> [[FBH]], splat (i32 -1) |
| 34 |
// DXCHECK-NEXT: select <3 x i1> %cmp.i, <3 x i32> splat (i32 -1), <3 x i32> [[SUB]] |
| 35 |
// CHECK-NEXT: ret <3 x i32> |
| 36 |
uint3 test_firstbithigh_ushort3(uint16_t3 p0) { |
| 37 |
return firstbithigh(p0); |
| 38 |
} |
| 39 |
|
| 40 |
// CHECK-LABEL: test_firstbithigh_ushort4 |
| 41 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<4 x i32> @llvm.[[TARGET]].firstbituhigh.v4i16 |
| 42 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <4 x i32> splat (i32 15), [[FBH]] |
| 43 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <4 x i32> [[FBH]], splat (i32 -1) |
| 44 |
// DXCHECK-NEXT: select <4 x i1> %cmp.i, <4 x i32> splat (i32 -1), <4 x i32> [[SUB]] |
| 45 |
// CHECK-NEXT: ret <4 x i32> |
| 46 |
uint4 test_firstbithigh_ushort4(uint16_t4 p0) { |
| 47 |
return firstbithigh(p0); |
| 48 |
} |
| 49 |
|
| 50 |
// CHECK-LABEL: test_firstbithigh_short |
| 51 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}i32 @llvm.[[TARGET]].firstbitshigh.i16 |
| 52 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub i32 15, [[FBH]] |
| 53 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq i32 [[FBH]], -1 |
| 54 |
// DXCHECK-NEXT: select i1 %cmp.i, i32 -1, i32 [[SUB]] |
| 55 |
// CHECK-NEXT: ret i32 |
| 56 |
uint test_firstbithigh_short(int16_t p0) { |
| 57 |
return firstbithigh(p0); |
| 58 |
} |
| 59 |
|
| 60 |
// CHECK-LABEL: test_firstbithigh_short2 |
| 61 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<2 x i32> @llvm.[[TARGET]].firstbitshigh.v2i16 |
| 62 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <2 x i32> splat (i32 15), [[FBH]] |
| 63 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <2 x i32> [[FBH]], splat (i32 -1) |
| 64 |
// DXCHECK-NEXT: select <2 x i1> %cmp.i, <2 x i32> splat (i32 -1), <2 x i32> [[SUB]] |
| 65 |
// CHECK-NEXT: ret <2 x i32> |
| 66 |
uint2 test_firstbithigh_short2(int16_t2 p0) { |
| 67 |
return firstbithigh(p0); |
| 68 |
} |
| 69 |
|
| 70 |
// CHECK-LABEL: test_firstbithigh_short3 |
| 71 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<3 x i32> @llvm.[[TARGET]].firstbitshigh.v3i16 |
| 72 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <3 x i32> splat (i32 15), [[FBH]] |
| 73 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <3 x i32> [[FBH]], splat (i32 -1) |
| 74 |
// DXCHECK-NEXT: select <3 x i1> %cmp.i, <3 x i32> splat (i32 -1), <3 x i32> [[SUB]] |
| 75 |
// CHECK-NEXT: ret <3 x i32> |
| 76 |
uint3 test_firstbithigh_short3(int16_t3 p0) { |
| 77 |
return firstbithigh(p0); |
| 78 |
} |
| 79 |
|
| 80 |
// CHECK-LABEL: test_firstbithigh_short4 |
| 81 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<4 x i32> @llvm.[[TARGET]].firstbitshigh.v4i16 |
| 82 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <4 x i32> splat (i32 15), [[FBH]] |
| 83 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <4 x i32> [[FBH]], splat (i32 -1) |
| 84 |
// DXCHECK-NEXT: select <4 x i1> %cmp.i, <4 x i32> splat (i32 -1), <4 x i32> [[SUB]] |
| 85 |
// CHECK-NEXT: ret <4 x i32> |
| 86 |
uint4 test_firstbithigh_short4(int16_t4 p0) { |
| 87 |
return firstbithigh(p0); |
| 88 |
} |
| 89 |
#endif // __HLSL_ENABLE_16_BIT |
| 90 |
|
| 91 |
// CHECK-LABEL: test_firstbithigh_uint |
| 92 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}i32 @llvm.[[TARGET]].firstbituhigh.i32 |
| 93 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub i32 31, [[FBH]] |
| 94 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq i32 [[FBH]], -1 |
| 95 |
// DXCHECK-NEXT: select i1 %cmp.i, i32 -1, i32 [[SUB]] |
| 96 |
// CHECK-NEXT: ret i32 |
| 97 |
uint test_firstbithigh_uint(uint p0) { |
| 98 |
return firstbithigh(p0); |
| 99 |
} |
| 100 |
|
| 101 |
// CHECK-LABEL: test_firstbithigh_uint2 |
| 102 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<2 x i32> @llvm.[[TARGET]].firstbituhigh.v2i32 |
| 103 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <2 x i32> splat (i32 31), [[FBH]] |
| 104 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <2 x i32> [[FBH]], splat (i32 -1) |
| 105 |
// DXCHECK-NEXT: select <2 x i1> %cmp.i, <2 x i32> splat (i32 -1), <2 x i32> [[SUB]] |
| 106 |
// CHECK-NEXT: ret <2 x i32> |
| 107 |
uint2 test_firstbithigh_uint2(uint2 p0) { |
| 108 |
return firstbithigh(p0); |
| 109 |
} |
| 110 |
|
| 111 |
// CHECK-LABEL: test_firstbithigh_uint3 |
| 112 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<3 x i32> @llvm.[[TARGET]].firstbituhigh.v3i32 |
| 113 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <3 x i32> splat (i32 31), [[FBH]] |
| 114 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <3 x i32> [[FBH]], splat (i32 -1) |
| 115 |
// DXCHECK-NEXT: select <3 x i1> %cmp.i, <3 x i32> splat (i32 -1), <3 x i32> [[SUB]] |
| 116 |
// CHECK-NEXT: ret <3 x i32> |
| 117 |
uint3 test_firstbithigh_uint3(uint3 p0) { |
| 118 |
return firstbithigh(p0); |
| 119 |
} |
| 120 |
|
| 121 |
// CHECK-LABEL: test_firstbithigh_uint4 |
| 122 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<4 x i32> @llvm.[[TARGET]].firstbituhigh.v4i32 |
| 123 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <4 x i32> splat (i32 31), [[FBH]] |
| 124 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <4 x i32> [[FBH]], splat (i32 -1) |
| 125 |
// DXCHECK-NEXT: select <4 x i1> %cmp.i, <4 x i32> splat (i32 -1), <4 x i32> [[SUB]] |
| 126 |
// CHECK-NEXT: ret <4 x i32> |
| 127 |
uint4 test_firstbithigh_uint4(uint4 p0) { |
| 128 |
return firstbithigh(p0); |
| 129 |
} |
| 130 |
|
| 131 |
// CHECK-LABEL: test_firstbithigh_ulong |
| 132 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}i32 @llvm.[[TARGET]].firstbituhigh.i64 |
| 133 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub i32 63, [[FBH]] |
| 134 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq i32 [[FBH]], -1 |
| 135 |
// DXCHECK-NEXT: select i1 %cmp.i, i32 -1, i32 [[SUB]] |
| 136 |
// CHECK-NEXT: ret i32 |
| 137 |
uint test_firstbithigh_ulong(uint64_t p0) { |
| 138 |
return firstbithigh(p0); |
| 139 |
} |
| 140 |
|
| 141 |
// CHECK-LABEL: test_firstbithigh_ulong2 |
| 142 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<2 x i32> @llvm.[[TARGET]].firstbituhigh.v2i64 |
| 143 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <2 x i32> splat (i32 63), [[FBH]] |
| 144 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <2 x i32> [[FBH]], splat (i32 -1) |
| 145 |
// DXCHECK-NEXT: select <2 x i1> %cmp.i, <2 x i32> splat (i32 -1), <2 x i32> [[SUB]] |
| 146 |
// CHECK-NEXT: ret <2 x i32> |
| 147 |
uint2 test_firstbithigh_ulong2(uint64_t2 p0) { |
| 148 |
return firstbithigh(p0); |
| 149 |
} |
| 150 |
|
| 151 |
// CHECK-LABEL: test_firstbithigh_ulong3 |
| 152 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<3 x i32> @llvm.[[TARGET]].firstbituhigh.v3i64 |
| 153 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <3 x i32> splat (i32 63), [[FBH]] |
| 154 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <3 x i32> [[FBH]], splat (i32 -1) |
| 155 |
// DXCHECK-NEXT: select <3 x i1> %cmp.i, <3 x i32> splat (i32 -1), <3 x i32> [[SUB]] |
| 156 |
// CHECK-NEXT: ret <3 x i32> |
| 157 |
uint3 test_firstbithigh_ulong3(uint64_t3 p0) { |
| 158 |
return firstbithigh(p0); |
| 159 |
} |
| 160 |
|
| 161 |
// CHECK-LABEL: test_firstbithigh_ulong4 |
| 162 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<4 x i32> @llvm.[[TARGET]].firstbituhigh.v4i64 |
| 163 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <4 x i32> splat (i32 63), [[FBH]] |
| 164 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <4 x i32> [[FBH]], splat (i32 -1) |
| 165 |
// DXCHECK-NEXT: select <4 x i1> %cmp.i, <4 x i32> splat (i32 -1), <4 x i32> [[SUB]] |
| 166 |
// CHECK-NEXT: ret <4 x i32> |
| 167 |
uint4 test_firstbithigh_ulong4(uint64_t4 p0) { |
| 168 |
return firstbithigh(p0); |
| 169 |
} |
| 170 |
|
| 171 |
// CHECK-LABEL: test_firstbithigh_int |
| 172 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}i32 @llvm.[[TARGET]].firstbitshigh.i32 |
| 173 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub i32 31, [[FBH]] |
| 174 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq i32 [[FBH]], -1 |
| 175 |
// DXCHECK-NEXT: select i1 %cmp.i, i32 -1, i32 [[SUB]] |
| 176 |
// CHECK-NEXT: ret i32 |
| 177 |
uint test_firstbithigh_int(int p0) { |
| 178 |
return firstbithigh(p0); |
| 179 |
} |
| 180 |
|
| 181 |
// CHECK-LABEL: test_firstbithigh_int2 |
| 182 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<2 x i32> @llvm.[[TARGET]].firstbitshigh.v2i32 |
| 183 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <2 x i32> splat (i32 31), [[FBH]] |
| 184 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <2 x i32> [[FBH]], splat (i32 -1) |
| 185 |
// DXCHECK-NEXT: select <2 x i1> %cmp.i, <2 x i32> splat (i32 -1), <2 x i32> [[SUB]] |
| 186 |
// CHECK-NEXT: ret <2 x i32> |
| 187 |
uint2 test_firstbithigh_int2(int2 p0) { |
| 188 |
return firstbithigh(p0); |
| 189 |
} |
| 190 |
|
| 191 |
// CHECK-LABEL: test_firstbithigh_int3 |
| 192 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<3 x i32> @llvm.[[TARGET]].firstbitshigh.v3i32 |
| 193 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <3 x i32> splat (i32 31), [[FBH]] |
| 194 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <3 x i32> [[FBH]], splat (i32 -1) |
| 195 |
// DXCHECK-NEXT: select <3 x i1> %cmp.i, <3 x i32> splat (i32 -1), <3 x i32> [[SUB]] |
| 196 |
// CHECK-NEXT: ret <3 x i32> |
| 197 |
uint3 test_firstbithigh_int3(int3 p0) { |
| 198 |
return firstbithigh(p0); |
| 199 |
} |
| 200 |
|
| 201 |
// CHECK-LABEL: test_firstbithigh_int4 |
| 202 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<4 x i32> @llvm.[[TARGET]].firstbitshigh.v4i32 |
| 203 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <4 x i32> splat (i32 31), [[FBH]] |
| 204 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <4 x i32> [[FBH]], splat (i32 -1) |
| 205 |
// DXCHECK-NEXT: select <4 x i1> %cmp.i, <4 x i32> splat (i32 -1), <4 x i32> [[SUB]] |
| 206 |
// CHECK-NEXT: ret <4 x i32> |
| 207 |
uint4 test_firstbithigh_int4(int4 p0) { |
| 208 |
return firstbithigh(p0); |
| 209 |
} |
| 210 |
|
| 211 |
// CHECK-LABEL: test_firstbithigh_long |
| 212 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}i32 @llvm.[[TARGET]].firstbitshigh.i64 |
| 213 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub i32 63, [[FBH]] |
| 214 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq i32 [[FBH]], -1 |
| 215 |
// DXCHECK-NEXT: select i1 %cmp.i, i32 -1, i32 [[SUB]] |
| 216 |
// CHECK-NEXT: ret i32 |
| 217 |
uint test_firstbithigh_long(int64_t p0) { |
| 218 |
return firstbithigh(p0); |
| 219 |
} |
| 220 |
|
| 221 |
// CHECK-LABEL: test_firstbithigh_long2 |
| 222 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<2 x i32> @llvm.[[TARGET]].firstbitshigh.v2i64 |
| 223 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <2 x i32> splat (i32 63), [[FBH]] |
| 224 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <2 x i32> [[FBH]], splat (i32 -1) |
| 225 |
// DXCHECK-NEXT: select <2 x i1> %cmp.i, <2 x i32> splat (i32 -1), <2 x i32> [[SUB]] |
| 226 |
// CHECK-NEXT: ret <2 x i32> |
| 227 |
uint2 test_firstbithigh_long2(int64_t2 p0) { |
| 228 |
return firstbithigh(p0); |
| 229 |
} |
| 230 |
|
| 231 |
// CHECK-LABEL: test_firstbithigh_long3 |
| 232 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<3 x i32> @llvm.[[TARGET]].firstbitshigh.v3i64 |
| 233 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <3 x i32> splat (i32 63), [[FBH]] |
| 234 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <3 x i32> [[FBH]], splat (i32 -1) |
| 235 |
// DXCHECK-NEXT: select <3 x i1> %cmp.i, <3 x i32> splat (i32 -1), <3 x i32> [[SUB]] |
| 236 |
// CHECK-NEXT: ret <3 x i32> |
| 237 |
uint3 test_firstbithigh_long3(int64_t3 p0) { |
| 238 |
return firstbithigh(p0); |
| 239 |
} |
| 240 |
|
| 241 |
// CHECK-LABEL: test_firstbithigh_long4 |
| 242 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<4 x i32> @llvm.[[TARGET]].firstbitshigh.v4i64 |
| 243 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <4 x i32> splat (i32 63), [[FBH]] |
| 244 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <4 x i32> [[FBH]], splat (i32 -1) |
| 245 |
// DXCHECK-NEXT: select <4 x i1> %cmp.i, <4 x i32> splat (i32 -1), <4 x i32> [[SUB]] |
| 246 |
// CHECK-NEXT: ret <4 x i32> |
| 247 |
uint4 test_firstbithigh_long4(int64_t4 p0) { |
| 248 |
return firstbithigh(p0); |
| 249 |
} |
| 250 |
|
| 251 |
// CHECK-LABEL: test_firstbithigh_upcast |
| 252 |
// CHECK: [[FBH:%.*]] = tail call {{.*}}<4 x i32> @llvm.[[TARGET]].firstbituhigh.v4i32(<4 x i32> %{{.*}}) |
| 253 |
// DXCHECK-NEXT: [[SUB:%.*]] = sub <4 x i32> splat (i32 31), [[FBH]] |
| 254 |
// DXCHECK-NEXT: [[ICMP:%.*]] = icmp eq <4 x i32> [[FBH]], splat (i32 -1) |
| 255 |
// DXCHECK-NEXT: select <4 x i1> %cmp.i, <4 x i32> splat (i32 -1), <4 x i32> [[SUB]] |
| 256 |
// CHECK-NEXT: [[ZEXT:%.*]] = zext <4 x i32> {{.*}} to <4 x i64> |
| 257 |
// CHECK-NEXT: ret <4 x i64> [[ZEXT]] |
| 258 |
uint64_t4 test_firstbithigh_upcast(uint4 p0) { |
| 259 |
return firstbithigh(p0); |
| 260 |
} |