Skip to content

Commit 40d08c2

Browse files
authored
[SYCL][ESIMD] Fix compilation break while using multiple bit shift functions (#6441)
* Fix multiple issues causing compilation break while using multiple bit shift functions
1 parent cf17fad commit 40d08c2

File tree

3 files changed

+182
-173
lines changed

3 files changed

+182
-173
lines changed

sycl/include/sycl/ext/intel/esimd/detail/elem_type_traits.hpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,13 +655,26 @@ struct computation_type<
655655
using Ty1 = element_type_t<T1>;
656656
using Ty2 = element_type_t<T2>;
657657
using EltTy = typename computation_type<Ty1, Ty2>::type;
658-
static constexpr int N1 = is_simd_like_type_v<T1> ? T1::length : 0;
659-
static constexpr int N2 = is_simd_like_type_v<T2> ? T2::length : 0;
660-
static_assert((N1 == N2) || ((N1 & N2) == 0), "size mismatch");
658+
659+
static constexpr int N1 = [] {
660+
if constexpr (is_simd_like_type_v<T1>) {
661+
return T1::length;
662+
} else {
663+
return 0;
664+
}
665+
}();
666+
static constexpr int N2 = [] {
667+
if constexpr (is_simd_like_type_v<T2>) {
668+
return T2::length;
669+
} else {
670+
return 0;
671+
}
672+
}();
673+
static_assert((N1 == N2) || (N1 == 0) || (N2 == 0), "size mismatch");
661674
static constexpr int N = N1 ? N1 : N2;
662675

663676
public:
664-
using type = simd<EltTy, N1>;
677+
using type = simd<EltTy, N>;
665678
};
666679

667680
template <class T1, class T2 = T1>

sycl/include/sycl/ext/intel/experimental/esimd/detail/math_intrin.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ __ESIMD_INTRIN __ESIMD_raw_vec_t(T0, SZ)
149149

150150
for (i = 0; i < SZ; i++) {
151151
SIMDCF_ELEMENT_SKIP(i);
152-
ret = src0.get(i) << src1.get(i);
152+
ret = src0[i] << src1[i];
153153
retv[i] = ret;
154154
}
155155
return retv;
@@ -167,7 +167,7 @@ __ESIMD_INTRIN __ESIMD_raw_vec_t(T0, SZ)
167167

168168
for (i = 0; i < SZ; i++) {
169169
SIMDCF_ELEMENT_SKIP(i);
170-
ret = src0.get(i) << src1.get(i);
170+
ret = src0[i] << src1[i];
171171
retv[i] = ret;
172172
}
173173
return retv;
@@ -185,7 +185,7 @@ __ESIMD_INTRIN __ESIMD_raw_vec_t(T0, SZ)
185185

186186
for (i = 0; i < SZ; i++) {
187187
SIMDCF_ELEMENT_SKIP(i);
188-
ret = src0.get(i) << src1.get(i);
188+
ret = src0[i] << src1[i];
189189
retv[i] = ret;
190190
}
191191
return retv;
@@ -203,7 +203,7 @@ __ESIMD_INTRIN __ESIMD_raw_vec_t(T0, SZ)
203203

204204
for (i = 0; i < SZ; i++) {
205205
SIMDCF_ELEMENT_SKIP(i);
206-
ret = src0.get(i) << src1.get(i);
206+
ret = src0[i] << src1[i];
207207
retv[i] = ret;
208208
}
209209
return retv;
@@ -221,7 +221,7 @@ __ESIMD_INTRIN __ESIMD_raw_vec_t(T0, SZ)
221221

222222
for (i = 0; i < SZ; i++) {
223223
SIMDCF_ELEMENT_SKIP(i);
224-
ret = src0.get(i) << src1.get(i);
224+
ret = src0[i] << src1[i];
225225
retv[i] = __ESIMD_EMU_DNS::satur<T0>::template saturate<T1>(ret, 1);
226226
}
227227
return retv;
@@ -239,7 +239,7 @@ __ESIMD_INTRIN __ESIMD_raw_vec_t(T0, SZ)
239239

240240
for (i = 0; i < SZ; i++) {
241241
SIMDCF_ELEMENT_SKIP(i);
242-
ret = src0.get(i) << src1.get(i);
242+
ret = src0[i] << src1[i];
243243
retv[i] = __ESIMD_EMU_DNS::satur<T0>::template saturate<T1>(ret, 1);
244244
}
245245
return retv;
@@ -257,7 +257,7 @@ __ESIMD_INTRIN __ESIMD_raw_vec_t(T0, SZ)
257257

258258
for (i = 0; i < SZ; i++) {
259259
SIMDCF_ELEMENT_SKIP(i);
260-
ret = src0.get(i) << src1.get(i);
260+
ret = src0[i] << src1[i];
261261
retv[i] = __ESIMD_EMU_DNS::satur<T0>::template saturate<T1>(ret, 1);
262262
}
263263
return retv;
@@ -275,7 +275,7 @@ __ESIMD_INTRIN __ESIMD_raw_vec_t(T0, SZ)
275275

276276
for (i = 0; i < SZ; i++) {
277277
SIMDCF_ELEMENT_SKIP(i);
278-
ret = src0.get(i) << src1.get(i);
278+
ret = src0[i] << src1[i];
279279
retv[i] = __ESIMD_EMU_DNS::satur<T0>::template saturate<T1>(ret, 1);
280280
}
281281
return retv;

0 commit comments

Comments
 (0)