Skip to content

Commit 8d67e26

Browse files
improved is_less_equal codegen on x86
1 parent 359a662 commit 8d67e26

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

include/eve/module/core/regular/impl/simd/x86/is_less.hpp

+13-11
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ namespace eve::detail
7474
else
7575
{
7676
constexpr auto use_avx2 = current_api >= avx2;
77+
constexpr auto use_avx = current_api >= avx;
7778
constexpr auto use_sse4_1 = current_api >= sse4_1;
7879
constexpr auto lt = []<typename E>(E ev, E fv) { return as_logical_t<E>(ev < fv); };
7980

@@ -84,17 +85,18 @@ namespace eve::detail
8485
return bit_cast((bit_cast(lhs, as(sm)) - sm) < (bit_cast(rhs, as(sm)) - sm), as<l_t>{});
8586
};
8687

87-
if constexpr (use_avx2 && c == category::int64x4) return _mm256_cmpgt_epi64(b, a);
88-
else if constexpr (use_avx2 && c == category::uint64x4) return unsigned_cmp(a, b);
89-
else if constexpr (use_avx2 && c == category::int32x8) return _mm256_cmpgt_epi32(b, a);
90-
else if constexpr (use_avx2 && c == category::uint32x8) return eve::min(a, b) != b;
91-
else if constexpr (use_avx2 && c == category::int16x16) return _mm256_cmpgt_epi16(b, a);
92-
else if constexpr (use_avx2 && c == category::uint16x16) return eve::min(a, b) != b;
93-
else if constexpr (use_avx2 && c == category::int8x32) return _mm256_cmpgt_epi8(b, a);
94-
else if constexpr (use_avx2 && c == category::uint8x32) return eve::min(a, b) != b;
95-
else if constexpr (c == category::int32x4) return _mm_cmplt_epi32(a, b);
96-
else if constexpr (c == category::int16x8) return _mm_cmplt_epi16(a, b);
97-
else if constexpr (c == category::int8x16) return _mm_cmplt_epi8(a, b);
88+
if constexpr (use_avx2 && c == category::int64x4) return _mm256_cmpgt_epi64(b, a);
89+
else if constexpr (use_avx2 && c == category::uint64x4) return unsigned_cmp(a, b);
90+
else if constexpr (use_avx2 && c == category::int32x8) return _mm256_cmpgt_epi32(b, a);
91+
else if constexpr (use_avx2 && c == category::uint32x8) return eve::min(a, b) != b;
92+
else if constexpr (use_avx2 && c == category::int16x16) return _mm256_cmpgt_epi16(b, a);
93+
else if constexpr (use_avx2 && c == category::uint16x16) return eve::min(a, b) != b;
94+
else if constexpr (use_avx2 && c == category::int8x32) return _mm256_cmpgt_epi8(b, a);
95+
else if constexpr (use_avx2 && c == category::uint8x32) return eve::min(a, b) != b;
96+
else if constexpr (use_avx && ((sizeof(T) * N::value) == 32)) return aggregate(is_less, a, b);
97+
else if constexpr (c == category::int32x4) return _mm_cmplt_epi32(a, b);
98+
else if constexpr (c == category::int16x8) return _mm_cmplt_epi16(a, b);
99+
else if constexpr (c == category::int8x16) return _mm_cmplt_epi8(a, b);
98100
else if constexpr (c == category::uint32x4)
99101
{
100102
if constexpr (use_sse4_1) return eve::min(a, b) != b;

include/eve/module/core/regular/impl/simd/x86/is_less_equal.hpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,18 @@ namespace eve::detail
6767
}
6868
else
6969
{
70-
if constexpr (c == category::float32x8) return _mm256_cmp_ps(a, b, f);
71-
else if constexpr (c == category::float64x4) return _mm256_cmp_pd(a, b, f);
72-
else if constexpr (c == category::float32x4) return _mm_cmple_ps(a, b);
73-
else if constexpr (c == category::float64x2) return _mm_cmple_pd(a, b);
74-
else return !(a > b);
70+
constexpr auto use_avx2 = current_api >= avx2;
71+
constexpr auto use_avx = current_api >= avx;
72+
constexpr auto use_sse4_1 = current_api >= sse4_1;
73+
74+
if constexpr (c == category::float32x8) return _mm256_cmp_ps(a, b, f);
75+
else if constexpr (c == category::float64x4) return _mm256_cmp_pd(a, b, f);
76+
else if constexpr (c == category::float32x4) return _mm_cmple_ps(a, b);
77+
else if constexpr (c == category::float64x2) return _mm_cmple_pd(a, b);
78+
else if constexpr (use_avx2) return eve::min(a, b) == a;
79+
else if constexpr (use_avx && ((sizeof(T) * N::value) == 32)) return aggregate(is_less_equal, a, b);
80+
else if constexpr (use_sse4_1) return eve::min(a, b) == a;
81+
else return !is_less(b, a);
7582
}
7683
}
7784
}

0 commit comments

Comments
 (0)