Skip to content

Commit

Permalink
Attempt to work around MSVC ICE
Browse files Browse the repository at this point in the history
  • Loading branch information
Epixu committed Feb 6, 2025
1 parent 68b158d commit 9348a2d
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 52 deletions.
5 changes: 1 addition & 4 deletions source/Fill.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ namespace Langulus::SIMD
}
else
#endif

#if LANGULUS_SIMD(256BIT)
if constexpr (R <= 32) {
using T = Decvq<TypeOf<decltype(s)>>;
Expand All @@ -47,7 +46,6 @@ namespace Langulus::SIMD
}
else
#endif

#if LANGULUS_SIMD(512BIT)
if constexpr (R <= 64) {
using T = Decvq<TypeOf<decltype(s)>>;
Expand All @@ -61,8 +59,7 @@ namespace Langulus::SIMD
}
else
#endif

return Unsupported {};
return Unsupported {};
}

} // namespace Langulus::SIMD
2 changes: 0 additions & 2 deletions source/Load.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ namespace Langulus::SIMD
}
else
#endif

#if LANGULUS_SIMD(256BIT)
if constexpr (RS <= 32) {
LANGULUS_SIMD_VERBOSE(
Expand All @@ -110,7 +109,6 @@ namespace Langulus::SIMD
}
else
#endif

#if LANGULUS_SIMD(512BIT)
if constexpr (RS <= 64) {
LANGULUS_SIMD_VERBOSE(
Expand Down
33 changes: 26 additions & 7 deletions source/Store.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Langulus::SIMD
using R = Deref<decltype(from)>;
using T = TypeOf<R>;

#if LANGULUS_SIMD(128BIT)
if constexpr (CT::SIMD128<R>) {
if constexpr (CT::Integer8<T>) to = simde_mm_movemask_epi8 (from);
else if constexpr (CT::Integer16<T>) to = simde_mm_movemask_epi8 (simde_mm_packs_epi16(from, from.Zero()));
Expand All @@ -32,7 +33,10 @@ namespace Langulus::SIMD
else if constexpr (CT::Double<T>) to = simde_mm_movemask_pd (from);
else static_assert(false, "Unsupported type");
}
else if constexpr (CT::SIMD256<R>) {
else
#endif
#if LANGULUS_SIMD(256BIT)
if constexpr (CT::SIMD256<R>) {
if constexpr (CT::Integer8<T>) to = simde_mm256_movemask_epi8(from);
else if constexpr (CT::Integer16<T>) {
const auto lo_lane = simde_mm256_castsi256_si128(from);
Expand All @@ -45,7 +49,10 @@ namespace Langulus::SIMD
else if constexpr (CT::Double<T>) to = simde_mm256_movemask_pd (from);
else static_assert(false, "Unsupported type");
}
else if constexpr (CT::SIMD512<R>) {
else
#endif
#if LANGULUS_SIMD(512BIT)
if constexpr (CT::SIMD512<R>) {
if constexpr (CT::Integer8<T>) to = simde_mm512_movemask_epi8(from);
else if constexpr (CT::Integer16<T>) {
const auto lo_lane = simde_mm512_castsi512_si256(from);
Expand All @@ -58,7 +65,9 @@ namespace Langulus::SIMD
else if constexpr (CT::Double<T>) to = simde_mm512_movemask_pd (from);
else static_assert(false, "Unsupported type");
}
else static_assert(false, "Unsupported register");
else
#endif
static_assert(false, "Unsupported register");
}

/// Save a register to a vector in memory
Expand All @@ -85,7 +94,9 @@ namespace Langulus::SIMD
StoreSIMD(from, mask);
mask.AsVector(to);
}
else if constexpr (CT::SIMD128<R>) {
else
#if LANGULUS_SIMD(128BIT)
if constexpr (CT::SIMD128<R>) {
if constexpr (CT::Float<T>) {
// To float array
if constexpr (sizeof(to) == sizeof(from)) {
Expand Down Expand Up @@ -140,7 +151,10 @@ namespace Langulus::SIMD
}
else static_assert(false, "Unsupported output");
}
else if constexpr (CT::SIMD256<R>) {
else
#endif
#if LANGULUS_SIMD(256BIT)
if constexpr (CT::SIMD256<R>) {
if constexpr (CT::Float<T>) {
// To float array
if constexpr (sizeof(to) == sizeof(from)) {
Expand Down Expand Up @@ -200,7 +214,10 @@ namespace Langulus::SIMD
}
else static_assert(false, "Unsupported output");
}
else if constexpr (CT::SIMD512<R>) {
else
#endif
#if LANGULUS_SIMD(512BIT)
if constexpr (CT::SIMD512<R>) {
if constexpr (CT::Float<T>) {
// To float array
if constexpr (sizeof(to) == sizeof(from)) {
Expand Down Expand Up @@ -260,7 +277,9 @@ namespace Langulus::SIMD
}
else static_assert(false, "Unsupported output");
}
else static_assert(false, "Unsupported register");
else
#endif
static_assert(false, "Unsupported register");
}

/// Fallback store routine, doesn't use SIMD, hopefully constexpr
Expand Down
15 changes: 12 additions & 3 deletions source/unary/Abs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace Langulus::SIMD
"Suboptimal and pointless for unsigned values");
(void)v;

#if LANGULUS_SIMD(128BIT)
if constexpr (CT::SIMD128<R>) {
if constexpr (CT::SignedInteger8<T>) return R {simde_mm_abs_epi8(v)};
else if constexpr (CT::SignedInteger16<T>) return R {simde_mm_abs_epi16(v)};
Expand All @@ -40,7 +41,10 @@ namespace Langulus::SIMD
else if constexpr (CT::Double<T>) return R {simde_mm_andnot_pd(simde_mm_set1_pd(-0.0F), v)};
else static_assert(false, "Unsupported type for 16-byte package");
}
else if constexpr (CT::SIMD256<R>) {
else
#endif
#if LANGULUS_SIMD(256BIT)
if constexpr (CT::SIMD256<R>) {
if constexpr (CT::SignedInteger8<T>) return R {simde_mm256_abs_epi8(v)};
else if constexpr (CT::SignedInteger16<T>) return R {simde_mm256_abs_epi16(v)};
else if constexpr (CT::SignedInteger32<T>) return R {simde_mm256_abs_epi32(v)};
Expand All @@ -49,7 +53,10 @@ namespace Langulus::SIMD
else if constexpr (CT::Double<T>) return R {simde_mm256_andnot_pd(simde_mm256_set1_pd(-0.0F), v)};
else static_assert(false, "Unsupported type for 32-byte package");
}
else if constexpr (CT::SIMD512<R>) {
else
#endif
#if LANGULUS_SIMD(512BIT)
if constexpr (CT::SIMD512<R>) {
if constexpr (CT::SignedInteger8<T>) return R {simde_mm512_abs_epi8(v)};
else if constexpr (CT::SignedInteger16<T>) return R {simde_mm512_abs_epi16(v)};
else if constexpr (CT::SignedInteger32<T>) return R {simde_mm512_abs_epi32(v)};
Expand All @@ -58,7 +65,9 @@ namespace Langulus::SIMD
else if constexpr (CT::Double<T>) return R {simde_mm512_andnot_pd(simde_mm512_set1_pd(-0.0F), v)};
else static_assert(false, "Unsupported type for 64-byte package");
}
else static_assert(false, "Unsupported type");
else
#endif
static_assert(false, "Unsupported type");
}

/// Get absolute values as constexpr, if possible
Expand Down
41 changes: 25 additions & 16 deletions source/unary/Ceil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,31 @@ namespace Langulus::SIMD
//TODO hopefully it is fixed in the future
return Unsupported {};
#else
if constexpr (CT::SIMD128<R>) {
if constexpr (CT::Float<T>) return R {simde_mm_ceil_ps (value)};
else if constexpr (CT::Double<T>) return R {simde_mm_ceil_pd (value)};
else static_assert(false, "Unsupported type for 16-byte package");
}
else if constexpr (CT::SIMD256<R>) {
if constexpr (CT::Float<T>) return R {simde_mm256_ceil_ps(value)};
else if constexpr (CT::Double<T>) return R {simde_mm256_ceil_pd(value)};
else static_assert(false, "Unsupported type for 32-byte package");
}
else if constexpr (CT::SIMD512<R>) {
if constexpr (CT::Float<T>) return R {simde_mm512_ceil_ps(value)};
else if constexpr (CT::Double<T>) return R {simde_mm512_ceil_pd(value)};
else static_assert(false, "Unsupported type for 64-byte package");
}
else static_assert(false, "Unsupported type");
#if LANGULUS_SIMD(128BIT)
if constexpr (CT::SIMD128<R>) {
if constexpr (CT::Float<T>) return R {simde_mm_ceil_ps (value)};
else if constexpr (CT::Double<T>) return R {simde_mm_ceil_pd (value)};
else static_assert(false, "Unsupported type for 16-byte package");
}
else
#endif
#if LANGULUS_SIMD(256BIT)
if constexpr (CT::SIMD256<R>) {
if constexpr (CT::Float<T>) return R {simde_mm256_ceil_ps(value)};
else if constexpr (CT::Double<T>) return R {simde_mm256_ceil_pd(value)};
else static_assert(false, "Unsupported type for 32-byte package");
}
else
#endif
#if LANGULUS_SIMD(512BIT)
if constexpr (CT::SIMD512<R>) {
if constexpr (CT::Float<T>) return R {simde_mm512_ceil_ps(value)};
else if constexpr (CT::Double<T>) return R {simde_mm512_ceil_pd(value)};
else static_assert(false, "Unsupported type for 64-byte package");
}
else
#endif
static_assert(false, "Unsupported type");
#endif
}

Expand Down
15 changes: 12 additions & 3 deletions source/unary/Floor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,31 @@ namespace Langulus::SIMD
//TODO hopefully it is fixed in the future
return Unsupported {};
#else
#if LANGULUS_SIMD(128BIT)
if constexpr (CT::SIMD128<R>) {
if constexpr (CT::Float<T>) return R {simde_mm_floor_ps (value)};
else if constexpr (CT::Double<T>) return R {simde_mm_floor_pd (value)};
else static_assert(false, "Unsupported type for 16-byte package");
}
else if constexpr (CT::SIMD256<R>) {
else
#endif
#if LANGULUS_SIMD(256BIT)
if constexpr (CT::SIMD256<R>) {
if constexpr (CT::Float<T>) return R {simde_mm256_floor_ps(value)};
else if constexpr (CT::Double<T>) return R {simde_mm256_floor_pd(value)};
else static_assert(false, "Unsupported type for 32-byte package");
}
else if constexpr (CT::SIMD512<R>) {
else
#endif
#if LANGULUS_SIMD(512BIT)
if constexpr (CT::SIMD512<R>) {
if constexpr (CT::Float<T>) return R {simde_mm512_floor_ps(value)};
else if constexpr (CT::Double<T>) return R {simde_mm512_floor_pd(value)};
else static_assert(false, "Unsupported type for 64-byte package");
}
else static_assert(false, "Unsupported type");
else
#endif
static_assert(false, "Unsupported type");
#endif
}

Expand Down
42 changes: 25 additions & 17 deletions source/unary/Round.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,31 @@ namespace Langulus::SIMD
return Unsupported {};
#else
constexpr auto STYLE = SIMDE_MM_FROUND_TO_NEAREST_INT | SIMDE_MM_FROUND_NO_EXC;

if constexpr (CT::SIMD128<R>) {
if constexpr (CT::Float<T>) return R {simde_mm_round_ps(value, STYLE)};
else if constexpr (CT::Double<T>) return R {simde_mm_round_pd(value, STYLE)};
else static_assert(false, "Unsupported type for 16-byte package");
}
else if constexpr (CT::SIMD256<R>) {
if constexpr (CT::Float<T>) return R {simde_mm256_round_ps(value, STYLE)};
else if constexpr (CT::Double<T>) return R {simde_mm256_round_pd(value, STYLE)};
else static_assert(false, "Unsupported type for 32-byte package");
}
else if constexpr (CT::SIMD512<R>) {
if constexpr (CT::Float<T>) return R {simde_mm512_roundscale_ps(value, STYLE)};
else if constexpr (CT::Double<T>) return R {simde_mm512_roundscale_pd(value, STYLE)};
else static_assert(false, "Unsupported type for 64-byte package");
}
else static_assert(false, "Unsupported type");
#if LANGULUS_SIMD(128BIT)
if constexpr (CT::SIMD128<R>) {
if constexpr (CT::Float<T>) return R {simde_mm_round_ps(value, STYLE)};
else if constexpr (CT::Double<T>) return R {simde_mm_round_pd(value, STYLE)};
else static_assert(false, "Unsupported type for 16-byte package");
}
else
#endif
#if LANGULUS_SIMD(256BIT)
if constexpr (CT::SIMD256<R>) {
if constexpr (CT::Float<T>) return R {simde_mm256_round_ps(value, STYLE)};
else if constexpr (CT::Double<T>) return R {simde_mm256_round_pd(value, STYLE)};
else static_assert(false, "Unsupported type for 32-byte package");
}
else
#endif
#if LANGULUS_SIMD(512BIT)
if constexpr (CT::SIMD512<R>) {
if constexpr (CT::Float<T>) return R {simde_mm512_roundscale_ps(value, STYLE)};
else if constexpr (CT::Double<T>) return R {simde_mm512_roundscale_pd(value, STYLE)};
else static_assert(false, "Unsupported type for 64-byte package");
}
else
#endif
static_assert(false, "Unsupported type");
#endif
}

Expand Down

0 comments on commit 9348a2d

Please sign in to comment.