Merge ktlim@zizzer:/bk/newmem
[gem5.git] / src / cpu / o3 / fetch_impl.hh
index 39a13f9f8800bc80e1a3f173d57e102617665e66..4045492ca53483f5a5e195d27f3ccce42511922c 100644 (file)
@@ -519,6 +519,11 @@ DefaultFetch<Impl>::fetchCacheLine(Addr fetch_PC, Fault &ret_fault, unsigned tid
     // Align the fetch PC so it's at the start of a cache block.
     fetch_PC = icacheBlockAlignPC(fetch_PC);
 
+    // If we've already got the block, no need to try to fetch it again.
+    if (fetch_PC == cacheDataPC[tid]) {
+        return true;
+    }
+
     // Setup the memReq to do a read of the first instruction's address.
     // Set the appropriate read size and flags as well.
     // Build request here.
@@ -552,6 +557,8 @@ DefaultFetch<Impl>::fetchCacheLine(Addr fetch_PC, Fault &ret_fault, unsigned tid
                                         Packet::ReadReq, Packet::Broadcast);
         data_pkt->dataDynamic(new uint8_t[cacheBlkSize]);
 
+        cacheDataPC[tid] = fetch_PC;
+
         DPRINTF(Fetch, "Fetch: Doing instruction read.\n");
 
         fetchedCacheLines++;