Skip to content

Commit df8178e

Browse files
majnemercopybara-github
authored andcommitted
Crc: Only test non_temporal_store_memcpy_avx on AVX targets
non_temporal_store_memcpy_avx uses gnu::target("avx") to use AVX intrinsics inside its function body even if the compiler was not configured for AVX support. This is OK because non_temporal_store_memcpy_avx is guarded by a cpuid check before it is called. However, non_temporal_memcpy_test.cc performs no such cpuid guard. In practice, nobody will really notice this bug as CPUs have had AVX for a long time by now. That said, this does come up if one has compiled absl for x86_64 and runs the binary on a arm64 Mac. This is because the Rosetta 2 emulation environment does not support AVX or newer instructions. PiperOrigin-RevId: 717991751 Change-Id: Id41bd186ebfd1cf7124ab5211fbfb74a01d5b56c
1 parent 1cdbba7 commit df8178e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

absl/crc/internal/non_temporal_memcpy_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ TEST_P(NonTemporalMemcpyTest, SSEEquality) {
5757
}
5858
}
5959

60+
#ifdef __AVX__
6061
TEST_P(NonTemporalMemcpyTest, AVXEquality) {
6162
uint8_t* src = a_.data() + GetParam().src_offset;
6263
uint8_t* dst = b_.data() + GetParam().dst_offset;
@@ -67,6 +68,7 @@ TEST_P(NonTemporalMemcpyTest, AVXEquality) {
6768
EXPECT_EQ(src[i], dst[i]);
6869
}
6970
}
71+
#endif
7072

7173
// 63B is smaller than one cacheline operation thus the non-temporal routine
7274
// will not be called.

0 commit comments

Comments
 (0)