cpu: Resolve targets of predicted 'taken' decode for O3
authorArthur Perais <arthur.perais@inria.fr>
Wed, 21 Dec 2016 21:05:24 +0000 (15:05 -0600)
committerArthur Perais <arthur.perais@inria.fr>
Wed, 21 Dec 2016 21:05:24 +0000 (15:05 -0600)
The target of taken conditional direct branches does not
need to be resolved in IEW: the target can be computed at
decode, usually using the decoded instruction word and the PC.

The higher-than-necessary penalty is taken only on conditional
branches that are predicted taken but miss in the BTB. Thus,
this is mostly inconsequential on IPC if the BTB is big/associative
enough (fewer capacity/conflict misses). Nonetheless, what gem5
simulates is not representative of how conditional branch targets
can be handled.

Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
src/cpu/o3/decode_impl.hh

index ca56ac1e442f04164211d1956d227c6421646a6e..15ec76f5a7d63eb566af27a1bce357a54eb399bf 100644 (file)
@@ -719,7 +719,11 @@ DefaultDecode<Impl>::decodeInsts(ThreadID tid)
         }
 
         // Go ahead and compute any PC-relative branches.
-        if (inst->isDirectCtrl() && inst->isUncondCtrl()) {
+        // This includes direct unconditional control and
+        // direct conditional control that is predicted taken.
+        if (inst->isDirectCtrl() &&
+           (inst->isUncondCtrl() || inst->readPredTaken()))
+        {
             ++decodeBranchResolved;
 
             if (!(inst->branchTarget() == inst->readPredTarg())) {