From ba58058f8334ffdf6fb2d7a4adbe049b5caeda26 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 9 Jun 2011 12:26:42 +0000 Subject: [PATCH] Use the precomputed sets_min_1 value consistently when masking off bits from an address to find which cache set it is in. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11809 --- cachegrind/cg_sim.c | 2 +- callgrind/sim.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cachegrind/cg_sim.c b/cachegrind/cg_sim.c index 0b8a1d7c96..d465bb3a84 100644 --- a/cachegrind/cg_sim.c +++ b/cachegrind/cg_sim.c @@ -139,7 +139,7 @@ void cachesim_##L##_doref(Addr a, UChar size, ULong* m1, ULong *mL) \ \ /* Second case: word straddles two lines. */ \ /* Nb: this is a fast way of doing ((set1+1) % L.sets) */ \ - } else if (((set1 + 1) & (L.sets-1)) == set2) { \ + } else if (((set1 + 1) & (L.sets_min_1)) == set2) { \ set = &(L.tags[set1 * L.assoc]); \ if (tag == set[0]) { \ goto block2; \ diff --git a/callgrind/sim.c b/callgrind/sim.c index 60b2987ccc..26f14bee89 100644 --- a/callgrind/sim.c +++ b/callgrind/sim.c @@ -286,7 +286,7 @@ static CacheResult cachesim_ref(cache_t2* c, Addr a, UChar size) /* Access straddles two lines. */ /* Nb: this is a fast way of doing ((set1+1) % c->sets) */ - else if (((set1 + 1) & (c->sets-1)) == set2) { + else if (((set1 + 1) & (c->sets_min_1)) == set2) { UWord tag2 = (a+size-1) >> c->tag_shift; /* the call updates cache structures as side effect */ @@ -390,7 +390,7 @@ CacheResult cachesim_ref_wb(cache_t2* c, RefType ref, Addr a, UChar size) /* Access straddles two lines. */ /* Nb: this is a fast way of doing ((set1+1) % c->sets) */ - else if (((set1 + 1) & (c->sets-1)) == set2) { + else if (((set1 + 1) & (c->sets_min_1)) == set2) { UWord tag2 = (a+size-1) & c->tag_mask; /* the call updates cache structures as side effect */ @@ -735,7 +735,7 @@ static CacheModelResult cacheuse##_##L##_doRead(Addr a, UChar size) \ \ /* Second case: word straddles two lines. */ \ /* Nb: this is a fast way of doing ((set1+1) % L.sets) */ \ - } else if (((set1 + 1) & (L.sets-1)) == set2) { \ + } else if (((set1 + 1) & (L.sets_min_1)) == set2) { \ Int miss1=0, miss2=0; /* 0: L1 hit, 1:L1 miss, 2:LL miss */ \ set = &(L.tags[set1 * L.assoc]); \ use_mask = L.line_start_mask[a & L.line_size_mask]; \ -- 2.47.2