Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: src/IceCfgNode.cpp

Issue 1271923002: Subzero: Slight improvement to phi lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceCfg.cpp ('k') | src/IceInst.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===// 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 // Guess that the number of live ranges beginning is roughly the 573 // Guess that the number of live ranges beginning is roughly the
574 // number of instructions, and same for live ranges ending. 574 // number of instructions, and same for live ranges ending.
575 LiveBegin->reserve(getInstCountEstimate()); 575 LiveBegin->reserve(getInstCountEstimate());
576 LiveEnd->reserve(getInstCountEstimate()); 576 LiveEnd->reserve(getInstCountEstimate());
577 } 577 }
578 // Initialize Live to be the union of all successors' LiveIn. 578 // Initialize Live to be the union of all successors' LiveIn.
579 for (CfgNode *Succ : OutEdges) { 579 for (CfgNode *Succ : OutEdges) {
580 Live |= Liveness->getLiveIn(Succ); 580 Live |= Liveness->getLiveIn(Succ);
581 // Mark corresponding argument of phis in successor as live. 581 // Mark corresponding argument of phis in successor as live.
582 for (Inst &I : Succ->Phis) { 582 for (Inst &I : Succ->Phis) {
583 if (I.isDeleted())
584 continue;
583 auto Phi = llvm::dyn_cast<InstPhi>(&I); 585 auto Phi = llvm::dyn_cast<InstPhi>(&I);
584 Phi->livenessPhiOperand(Live, this, Liveness); 586 Phi->livenessPhiOperand(Live, this, Liveness);
585 } 587 }
586 } 588 }
587 Liveness->getLiveOut(this) = Live; 589 Liveness->getLiveOut(this) = Live;
588 590
589 // Process regular instructions in reverse order. 591 // Process regular instructions in reverse order.
590 for (Inst &I : reverse_range(Insts)) { 592 for (Inst &I : reverse_range(Insts)) {
591 if (I.isDeleted()) 593 if (I.isDeleted())
592 continue; 594 continue;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 // the Variable's live range begins and ends in this block. If 693 // the Variable's live range begins and ends in this block. If
692 // i1<i2, then i1's live range begins at instruction IBB->second 694 // i1<i2, then i1's live range begins at instruction IBB->second
693 // and extends through the end of the block. If i1>i2, then i2's 695 // and extends through the end of the block. If i1>i2, then i2's
694 // live range begins at the first instruction of the block and 696 // live range begins at the first instruction of the block and
695 // ends at IEB->second. In any case, we choose the lesser of i1 697 // ends at IEB->second. In any case, we choose the lesser of i1
696 // and i2 and proceed accordingly. 698 // and i2 and proceed accordingly.
697 InstNumberT LB = i == i1 ? IBB->second : FirstInstNum; 699 InstNumberT LB = i == i1 ? IBB->second : FirstInstNum;
698 InstNumberT LE = i == i2 ? IEB->second : LastInstNum + 1; 700 InstNumberT LE = i == i2 ? IEB->second : LastInstNum + 1;
699 701
700 Variable *Var = Liveness->getVariable(i, this); 702 Variable *Var = Liveness->getVariable(i, this);
701 if (!Var->getIgnoreLiveness()) { 703 if (!Var->getIgnoreLiveness()) {
jvoung (off chromium) 2015/08/05 19:32:26 There was also this getIgnoreLiveness, but that so
Jim Stichnoth 2015/08/05 23:18:54 That's true. But it seems like I could set it up
702 if (LB > LE) { 704 if (LB > LE) {
703 Var->addLiveRange(FirstInstNum, LE, 1); 705 Var->addLiveRange(FirstInstNum, LE, 1);
704 Var->addLiveRange(LB, LastInstNum + 1, 1); 706 Var->addLiveRange(LB, LastInstNum + 1, 1);
705 // Assert that Var is a global variable by checking that its 707 // Assert that Var is a global variable by checking that its
706 // liveness index is less than the number of globals. This 708 // liveness index is less than the number of globals. This
707 // ensures that the LiveInAndOut[] access is valid. 709 // ensures that the LiveInAndOut[] access is valid.
708 assert(i < Liveness->getNumGlobalVars()); 710 assert(i < Liveness->getNumGlobalVars());
709 LiveInAndOut[i] = false; 711 LiveInAndOut[i] = false;
710 } else { 712 } else {
711 Var->addLiveRange(LB, LE, 1); 713 Var->addLiveRange(LB, LE, 1);
712 } 714 }
713 } 715 }
714 if (i == i1) 716 if (i == i1)
715 ++IBB; 717 ++IBB;
716 if (i == i2) 718 if (i == i2)
717 ++IEB; 719 ++IEB;
718 } 720 }
719 // Process the variables that are live across the entire block. 721 // Process the variables that are live across the entire block.
720 for (int i = LiveInAndOut.find_first(); i != -1; 722 for (int i = LiveInAndOut.find_first(); i != -1;
721 i = LiveInAndOut.find_next(i)) { 723 i = LiveInAndOut.find_next(i)) {
722 Variable *Var = Liveness->getVariable(i, this); 724 Variable *Var = Liveness->getVariable(i, this);
723 Var->addLiveRange(FirstInstNum, LastInstNum + 1, 1); 725 if (Liveness->getRangeMask(Var->getIndex()))
726 Var->addLiveRange(FirstInstNum, LastInstNum + 1, 1);
724 } 727 }
725 } 728 }
726 729
727 // If this node contains only deleted instructions, and ends in an 730 // If this node contains only deleted instructions, and ends in an
728 // unconditional branch, contract the node by repointing all its 731 // unconditional branch, contract the node by repointing all its
729 // in-edges to its successor. 732 // in-edges to its successor.
730 void CfgNode::contractIfEmpty() { 733 void CfgNode::contractIfEmpty() {
731 if (InEdges.empty()) 734 if (InEdges.empty())
732 return; 735 return;
733 Inst *Branch = nullptr; 736 Inst *Branch = nullptr;
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 InstIntrinsicCall *Inst = InstIntrinsicCall::create( 1280 InstIntrinsicCall *Inst = InstIntrinsicCall::create(
1278 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); 1281 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info);
1279 Inst->addArg(AtomicRMWOp); 1282 Inst->addArg(AtomicRMWOp);
1280 Inst->addArg(Counter); 1283 Inst->addArg(Counter);
1281 Inst->addArg(One); 1284 Inst->addArg(One);
1282 Inst->addArg(OrderAcquireRelease); 1285 Inst->addArg(OrderAcquireRelease);
1283 Insts.push_front(Inst); 1286 Insts.push_front(Inst);
1284 } 1287 }
1285 1288
1286 } // end of namespace Ice 1289 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfg.cpp ('k') | src/IceInst.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698