From 096b1472c546f9c761459ae0af18a99ce30c523d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 10 Jun 2008 06:32:49 +0000 Subject: [PATCH] Only enable the cache rotation optimization for gcc 4.2 and later. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8212 --- exp-drd/drd_bitmap.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/exp-drd/drd_bitmap.h b/exp-drd/drd_bitmap.h index 969ea1e1ec..4f510c8315 100644 --- a/exp-drd/drd_bitmap.h +++ b/exp-drd/drd_bitmap.h @@ -204,12 +204,19 @@ static struct bitmap2* bm2_make_exclusive(struct bitmap* const bm, /** Rotate elements cache[0..n-1] such that the element at position n-1 is * moved to position 0. This allows to speed up future cache lookups. + * + * @note Apparently gcc 4.2 compiles this code correctly, but gcc 4.1 not. */ static __inline__ void bm_cache_rotate(struct bm_cache_elem cache[], const int n) { +#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 2 struct bm_cache_elem t; +#if 0 + tl_assert(2 <= n && n <= 8); +#endif + t = cache[0]; if (n > 1) cache[0] = cache[1]; @@ -226,6 +233,7 @@ void bm_cache_rotate(struct bm_cache_elem cache[], const int n) if (n > 7) cache[6] = cache[7]; cache[n - 1] = t; +#endif } static __inline__ -- 2.47.2