Skip to content

Commit d5c556b

Browse files
feat: update cast<> function to reduce spurious cast functions (cases
like integer to float or vice versa)
1 parent d2f8229 commit d5c556b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

crates/intrinsic-test/src/x86/config.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,9 @@ pub const PLATFORM_C_FORWARD_DECLARATIONS: &str = r#"
320320
#define _mm256_loadu_epi64_to___m256(mem_addr) _mm256_castsi256_ps(_mm256_loadu_si256((__m256i const*)(mem_addr)))
321321
#define _mm512_loadu_epi64_to___m512(mem_addr) _mm512_castsi512_ps(_mm512_loadu_si512((__m512i const*)(mem_addr)))
322322
323-
324323
// T1 is the `To` type, T2 is the `From` type
325324
template<typename T1, typename T2> T1 cast(T2 x) {
326-
if constexpr (std::is_convertible_v<T2, T1>) {
325+
if constexpr ((std::is_integral_v<T1> && std::is_integral_v<T2>) || (std::is_floating_point_v<T1> && std::is_floating_point_v<T2>)) {
327326
return x;
328327
} else if constexpr (sizeof(T1) == sizeof(T2)) {
329328
T1 ret{};

0 commit comments

Comments
 (0)