From bbdb1be1e91bccedf54f70a6df25c0c788f2d52e Mon Sep 17 00:00:00 2001 From: Jan Wassenberg Date: Thu, 7 Jul 2022 07:57:32 -0700 Subject: [PATCH] RVV warning fixes for GCC. Refs #838 PiperOrigin-RevId: 459513304 --- hwy/ops/rvv-inl.h | 29 +++++++++++++++++------------ hwy/tests/shift_test.cc | 3 ++- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/hwy/ops/rvv-inl.h b/hwy/ops/rvv-inl.h index 67fd8c7119..0d751397bb 100644 --- a/hwy/ops/rvv-inl.h +++ b/hwy/ops/rvv-inl.h @@ -2066,7 +2066,8 @@ template HWY_INLINE MFromD FirstNPerBlock(D /* tag */) { const RebindToUnsigned du; const RebindToSigned di; - const auto idx_mod = AndS(Iota0(du), LanesPerBlock(du) - 1); + using TU = TFromD; + const auto idx_mod = AndS(Iota0(du), static_cast(LanesPerBlock(du) - 1)); return LtS(BitCast(di, idx_mod), static_cast>(kLanes)); } @@ -2601,7 +2602,7 @@ HWY_API VI TableLookupBytes(const VT vt, const VI vi) { // If the table is shorter, wrap around offsets so they do not reference // undefined lanes in the newly extended vmt. if (kPow2T < kPow2I) { - offsets = detail::AndS(offsets, Lanes(dt8) - 1); + offsets = detail::AndS(offsets, static_cast(Lanes(dt8) - 1)); } const auto out = TableLookupLanes(vmt, Add(vmi, offsets)); return BitCast(di, detail::ChangeLMUL(di8, out)); @@ -2636,8 +2637,8 @@ HWY_API V ShiftLeftLanes(const D d, const V v) { using TI = TFromD; const auto shifted = detail::SlideUp(v, v, kLanes); // Match x86 semantics by zeroing lower lanes in 128-bit blocks - const auto idx_mod = - detail::AndS(detail::Iota0(di), detail::LanesPerBlock(di) - 1); + const auto idx_mod = detail::AndS( + detail::Iota0(di), static_cast(detail::LanesPerBlock(di) - 1)); const auto clear = detail::LtS(BitCast(di, idx_mod), static_cast(kLanes)); return IfThenZeroElse(clear, shifted); } @@ -2674,7 +2675,8 @@ HWY_API V ShiftRightLanes(const Simd d, V v) { const auto shifted = detail::SlideDown(v, v, kLanes); // Match x86 semantics by zeroing upper lanes in 128-bit blocks const size_t lpb = detail::LanesPerBlock(di); - const auto idx_mod = detail::AndS(detail::Iota0(di), lpb - 1); + const auto idx_mod = + detail::AndS(detail::Iota0(di), static_cast(lpb - 1)); const auto keep = detail::LtS(BitCast(di, idx_mod), static_cast(lpb - kLanes)); return IfThenElseZero(keep, shifted); @@ -2693,9 +2695,10 @@ template HWY_API V InterleaveLower(D d, const V a, const V b) { static_assert(IsSame, TFromV>(), "D/V mismatch"); const RebindToUnsigned du; + using TU = TFromD; const auto i = detail::Iota0(du); - const auto idx_mod = - ShiftRight<1>(detail::AndS(i, detail::LanesPerBlock(du) - 1)); + const auto idx_mod = ShiftRight<1>( + detail::AndS(i, static_cast(detail::LanesPerBlock(du) - 1))); const auto idx = Add(idx_mod, detail::OffsetsOf128BitBlocks(d, i)); const auto is_even = detail::EqS(detail::AndS(i, 1), 0u); return IfThenElse(is_even, TableLookupLanes(a, idx), @@ -2713,11 +2716,12 @@ template HWY_API V InterleaveUpper(const D d, const V a, const V b) { static_assert(IsSame, TFromV>(), "D/V mismatch"); const RebindToUnsigned du; + using TU = TFromD; const size_t lpb = detail::LanesPerBlock(du); const auto i = detail::Iota0(du); - const auto idx_mod = ShiftRight<1>(detail::AndS(i, lpb - 1)); + const auto idx_mod = ShiftRight<1>(detail::AndS(i, static_cast(lpb - 1))); const auto idx_lower = Add(idx_mod, detail::OffsetsOf128BitBlocks(d, i)); - const auto idx = detail::AddS(idx_lower, lpb / 2); + const auto idx = detail::AddS(idx_lower, static_cast(lpb / 2)); const auto is_even = detail::EqS(detail::AndS(i, 1), 0u); return IfThenElse(is_even, TableLookupLanes(a, idx), TableLookupLanes(b, idx)); @@ -2818,11 +2822,12 @@ HWY_API V PopulationCount(V v) { // ------------------------------ LoadDup128 -template -HWY_API VFromD LoadDup128(D d, const TFromD* const HWY_RESTRICT p) { +template > +HWY_API VFromD LoadDup128(D d, const T* const HWY_RESTRICT p) { const auto loaded = Load(d, p); // Broadcast the first block - const auto idx = detail::AndS(detail::Iota0(d), detail::LanesPerBlock(d) - 1); + const auto idx = detail::AndS(detail::Iota0(d), + static_cast(detail::LanesPerBlock(d) - 1)); return TableLookupLanes(loaded, idx); } diff --git a/hwy/tests/shift_test.cc b/hwy/tests/shift_test.cc index e644add095..14270b59f0 100644 --- a/hwy/tests/shift_test.cc +++ b/hwy/tests/shift_test.cc @@ -44,7 +44,8 @@ struct TestLeftShifts { const size_t N = Lanes(d); auto expected = AllocateAligned(N); - const auto values = Iota(d, kSigned ? -TI(N) : TI(0)); // value to shift + // Values to shift + const auto values = Iota(d, static_cast(kSigned ? -TI(N) : TI(0))); constexpr size_t kMaxShift = (sizeof(T) * 8) - 1; // 0