@@ -245,34 +245,39 @@ DecoupledBPUWithBTB::generateFinalPredAndCreateBubbles()
245245
246246 if (predsOfEachStage[0 ].btbEntries .size () != 0 ) {
247247 for (auto entry : predsOfEachStage[0 ].btbEntries ){
248- if (entry.isIndirect || entry.isDirect || entry.ctr >=0 ||entry.alwaysTaken ){
248+ if (entry.isIndirect || entry.isDirect || entry.ctr >= 0 ||entry.alwaysTaken ){
249249 finalPred.s1Source = entry.source ;
250250 break ;
251251 }
252252 }
253253 }
254254
255- if (predsOfEachStage[2 ].btbEntries .size () != 0 ) {
255+ bool found_s3_taken = false ;
256+ bool na_s3_taken_but_have_cond = false ;
257+
258+ for (BTBEntry entry : predsOfEachStage[2 ].btbEntries ) {
259+ if (entry.isDirect || entry.isIndirect || entry.ctr >= 0 || entry.alwaysTaken ) {
260+ found_s3_taken = true ;
261+ }else if (entry.isCond ){
262+ // only use when there's no taken prediction in s3
263+ na_s3_taken_but_have_cond = true ;
264+ }
265+ }
266+
267+ if (found_s3_taken) {
256268 auto pred_taken_entry = finalPred.getTakenEntry ();
257269 if (pred_taken_entry.valid ) {
258270 if (pred_taken_entry.isReturn ) {
259271 finalPred.s3Source = ras->getComponentIdx ();
260- } else if (pred_taken_entry.isIndirect ) {
272+ } else if (pred_taken_entry.isIndirect && ittage-> tageHit () ) {
261273 finalPred.s3Source = ittage->getComponentIdx ();
262274 }else if (pred_taken_entry.isCond ) {
263275 finalPred.s3Source = tage->getComponentIdx ();
264276 } else {
265277 finalPred.s3Source = mbtb->getComponentIdx ();
266278 }
267279 }else {
268- bool found = false ;
269- for (auto entry : predsOfEachStage[2 ].btbEntries ) {
270- if (entry.isCond ){
271- found = true ;
272- break ;
273- }
274- }
275- if (found) {
280+ if (na_s3_taken_but_have_cond) {
276281 finalPred.s3Source = tage->getComponentIdx ();
277282 }else {
278283 finalPred.s3Source = -1 ;
0 commit comments