GBE: optimize JMP instruction.
authorZhigang Gong <zhigang.gong@intel.com>
Fri, 3 Jan 2014 09:15:58 +0000 (17:15 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Tue, 7 Jan 2014 07:50:55 +0000 (15:50 +0800)
If the pred register is not in the liveIn set, it means this register
is defined in this block. Then we don't need to validate it.

Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
backend/src/backend/gen_insn_selection.cpp

index 74a1e70..445fd6d 100644 (file)
@@ -3031,12 +3031,22 @@ namespace gbe
 
     // Get active pred.
     const ir::Register getActivePred(Selection::Opaque &sel,
+                       const ir::BranchInstruction &insn,
                        const ir::Register pred) const
     {
         using namespace ir;
         GenRegister flagReg;
-        Register activePred = sel.reg(FAMILY_BOOL);
-
+        Register activePred;
+        const ir::BasicBlock *insnBlock = insn.getParent();
+        const ir::Liveness &liveness = sel.ctx.getLiveness();
+        const ir::Liveness::UEVar &livein = liveness.getLiveIn(insnBlock);
+       
+        /* If the pred is not in the livein set, then this pred should be defined
+           in this block and we don't need to validate it. */ 
+        if (!livein.contains(pred))
+          return pred;
+
+        activePred = sel.reg(FAMILY_BOOL);
         sel.push();
           sel.curr.predicate = GEN_PREDICATE_NONE;
           sel.curr.execWidth = 1;
@@ -3067,7 +3077,7 @@ namespace gbe
 
       if (insn.isPredicated() == true) {
         const Register pred = insn.getPredicateIndex();
-        const Register activePred = getActivePred(sel, pred);
+        const Register activePred = getActivePred(sel, insn, pred);
 
         // Update the PcIPs
         sel.push();
@@ -3140,7 +3150,7 @@ namespace gbe
 
       if (insn.isPredicated() == true) {
         const Register pred = insn.getPredicateIndex();
-        const Register activePred = getActivePred(sel, pred);
+        const Register activePred = getActivePred(sel, insn, pred);
 
         // Update the PcIPs for all the branches. Just put the IPs of the next
         // block. Next instruction will properly reupdate the IPs of the lanes