mem-ruby: Fix type casting in makeNextStrideAddress
authorseanzw <seanyukigeek@gmail.com>
Tue, 14 Jul 2020 22:51:59 +0000 (15:51 -0700)
committerZHENGRONG WANG <seanzw@g.ucla.edu>
Wed, 15 Jul 2020 17:38:12 +0000 (17:38 +0000)
The RubyPrefetcher uses makeNextStrideAddress() with
a negative stride to find prefetched address.
The type of this expression is:
uint64_t + uint32_t * int;
This gives wrong result due to implicit conversion.
Fix this with static cast and it works correctly:
uint64_t + int * int;

Change-Id: I36e17e00d5c66c3699fe1d5b287971225a162d04
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/31314
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/mem/ruby/common/Address.cc

index 39de974a572c66b26b47d15ad7b81ab190c58766..fd3c43e1bfbb9d0a159d3e393b6016e89be3ae4f 100644 (file)
@@ -66,7 +66,8 @@ makeLineAddress(Addr addr, int cacheLineBits)
 Addr
 makeNextStrideAddress(Addr addr, int stride)
 {
-    return makeLineAddress(addr) + RubySystem::getBlockSizeBytes() * stride;
+    return makeLineAddress(addr) +
+        static_cast<int>(RubySystem::getBlockSizeBytes()) * stride;
 }
 
 std::string