Fix division by zero UB in packet size logic.

This commit is contained in:
Antonio Sánchez 2024-02-12 21:01:19 +00:00
parent 186f8205db
commit 9229cfa822

View File

@ -2399,7 +2399,7 @@ EIGEN_DONT_INLINE void gebp_kernel<LhsScalar, RhsScalar, Index, DataMapper, mr,
// fails, drop down to the scalar path. // fails, drop down to the scalar path.
constexpr bool kCanLoadSRhsQuad = constexpr bool kCanLoadSRhsQuad =
(unpacket_traits<SLhsPacket>::size < 4) || (unpacket_traits<SLhsPacket>::size < 4) ||
(unpacket_traits<SRhsPacket>::size % (unpacket_traits<SLhsPacket>::size / 4)) == 0; (unpacket_traits<SRhsPacket>::size % ((std::max<int>)(unpacket_traits<SLhsPacket>::size, 4) / 4)) == 0;
if (kCanLoadSRhsQuad && (SwappedTraits::LhsProgress % 4) == 0 && (SwappedTraits::LhsProgress <= 16) && if (kCanLoadSRhsQuad && (SwappedTraits::LhsProgress % 4) == 0 && (SwappedTraits::LhsProgress <= 16) &&
(SwappedTraits::LhsProgress != 8 || SResPacketHalfSize == nr) && (SwappedTraits::LhsProgress != 8 || SResPacketHalfSize == nr) &&
(SwappedTraits::LhsProgress != 16 || SResPacketQuarterSize == nr)) { (SwappedTraits::LhsProgress != 16 || SResPacketQuarterSize == nr)) {