msvc warning fixes
PiperOrigin-RevId: 350374851
diff --git a/hwy/targets_test.cc b/hwy/targets_test.cc
index bbf2f06..ba65413 100644
--- a/hwy/targets_test.cc
+++ b/hwy/targets_test.cc
@@ -85,7 +85,7 @@
return;
}
// Get the lowest bit in the mask (the best target) and disable that one.
- uint32_t lowest_target = current_targets & (-current_targets);
+ uint32_t lowest_target = current_targets & (~current_targets + 1);
// The lowest target shouldn't be one in the baseline.
HWY_ASSERT((lowest_target & ~HWY_ENABLED_BASELINE) != 0);
DisableTargets(lowest_target);
diff --git a/hwy/tests/arithmetic_test.cc b/hwy/tests/arithmetic_test.cc
index ee9d5b8..dc10ec3 100644
--- a/hwy/tests/arithmetic_test.cc
+++ b/hwy/tests/arithmetic_test.cc
@@ -405,7 +405,7 @@
// We want a right-shift here, which is undefined behavior for negative
// numbers. Since we want (-1)>>1 to be -1, we need to adjust rounding if
// minT is odd and negative.
- T minT = min + i;
+ T minT = static_cast<T>(min + i);
expected[i] = T(minT / 2 + (minT < 0 ? minT % 2 : 0));
}
HWY_ASSERT_VEC_EQ(d, expected.get(), vn >> Set(d, 1));
diff --git a/hwy/tests/compare_test.cc b/hwy/tests/compare_test.cc
index a3df62c..1cab931 100644
--- a/hwy/tests/compare_test.cc
+++ b/hwy/tests/compare_test.cc
@@ -56,7 +56,7 @@
const size_t N = Lanes(d);
auto all_false = AllocateAligned<T>(N);
auto all_true = AllocateAligned<T>(N);
- std::fill(all_false.get(), all_false.get() + N, 0);
+ std::fill(all_false.get(), all_false.get() + N, T(0));
memset(all_true.get(), 0xFF, N * sizeof(T));
HWY_ASSERT_VEC_EQ(d, all_true.get(), VecFromMask(v2 > vn));
diff --git a/hwy/tests/list_targets.cc b/hwy/tests/list_targets.cc
index 351073b..4b0cdce 100644
--- a/hwy/tests/list_targets.cc
+++ b/hwy/tests/list_targets.cc
@@ -22,7 +22,7 @@
void PrintTargets(const char* msg, uint32_t targets) {
fprintf(stderr, "%s", msg);
for (unsigned x = targets; x != 0; x = x & (x - 1)) {
- fprintf(stderr, " %s", hwy::TargetName(x & (-x)));
+ fprintf(stderr, " %s", hwy::TargetName(x & (~x + 1)));
}
fprintf(stderr, "\n");
}
diff --git a/hwy/tests/swizzle_test.cc b/hwy/tests/swizzle_test.cc
index fe28471..b685e1f 100644
--- a/hwy/tests/swizzle_test.cc
+++ b/hwy/tests/swizzle_test.cc
@@ -278,7 +278,7 @@
const D d;
const size_t N = Lanes(d);
auto in_lanes = AllocateAligned<T>(N);
- std::fill(in_lanes.get(), in_lanes.get() + N, 0);
+ std::fill(in_lanes.get(), in_lanes.get() + N, T(0));
const size_t blockN = HWY_MIN(N * sizeof(T), 16) / sizeof(T);
// Need to set within each 128-bit block
for (size_t block = 0; block < N; block += blockN) {