Skip to content

Commit 4cb8561

Browse files
[ESIMD] Fix negation operator to return a mask (#4353)
1 parent b3db5e5 commit 4cb8561

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ template <typename BaseTy, typename RegionTy> class simd_view_impl {
289289
auto V = UNARY_OP(read().data()); \
290290
return simd<element_type, length>(V); \
291291
}
292-
DEF_UNARY_OP(!)
293292
DEF_UNARY_OP(~)
294293
DEF_UNARY_OP(+)
295294
DEF_UNARY_OP(-)

sycl/include/sycl/ext/intel/experimental/esimd/simd.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,15 @@ template <typename Ty, int N> class simd {
352352
auto V = UNARY_OP(data()); \
353353
return simd(V); \
354354
}
355-
DEF_UNARY_OP(!)
356355
DEF_UNARY_OP(~)
357356
DEF_UNARY_OP(+)
358357
DEF_UNARY_OP(-)
359358

360359
#undef DEF_UNARY_OP
361360

361+
// negation operator
362+
auto operator!() { return *this == 0; }
363+
362364
/// \name Replicate
363365
/// Replicate simd instance given a region.
364366
/// @{

sycl/include/sycl/ext/intel/experimental/esimd/simd_view.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class simd_view : public detail::simd_view_impl<BaseTy, RegionTy> {
9090
DEF_RELOP(!=)
9191

9292
#undef DEF_RELOP
93+
94+
// negation operator
95+
auto operator!() { return *this == 0; }
9396
};
9497

9598
/// This is a specialization of simd_view class with a single element.
@@ -142,6 +145,9 @@ class simd_view<BaseTy, region_base_1<typename BaseTy::element_type>>
142145
DEF_RELOP(!=)
143146

144147
#undef DEF_RELOP
148+
149+
// negation operator
150+
auto operator!() { return *this == 0; }
145151
};
146152

147153
} // namespace esimd

sycl/test/esimd/simd_view.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SYCL_ESIMD_FUNCTION bool test_simd_view_unary_ops() {
3131
ref0 <<= ref1;
3232
ref1 = -ref0;
3333
ref0 = ~ref1;
34-
ref1 = !ref0;
34+
auto mask = !ref0;
3535
return v1[0] == 1;
3636
}
3737

0 commit comments

Comments
 (0)