diff options
author | ckoenig <ckoenig@91177308-0d34-0410-b5e6-96231b3b80d8> | 2013-02-16 11:27:40 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2013-02-19 15:00:25 +0000 |
commit | 25bc9dbc8f637977b6948e69644446202144161a (patch) | |
tree | a51cb69371a303d23a4d296c9add2c05aaecf769 | |
parent | 6ed8c0f164e977a4d298f5abc3a587178e14caab (diff) |
R600/structurizer: improve finding condition values
Using the new NearestCommonDominator class.
This is a candidate for the stable branch.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175347 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit f9459f12d2eefd122a797051be0e2704c249ae13)
Conflicts:
lib/Target/R600/AMDGPUStructurizeCFG.cpp
-rw-r--r-- | lib/Target/R600/AMDGPUStructurizeCFG.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/Target/R600/AMDGPUStructurizeCFG.cpp b/lib/Target/R600/AMDGPUStructurizeCFG.cpp index eb63e556209..306f0cdea9a 100644 --- a/lib/Target/R600/AMDGPUStructurizeCFG.cpp +++ b/lib/Target/R600/AMDGPUStructurizeCFG.cpp @@ -458,28 +458,41 @@ void AMDGPUStructurizeCFG::insertConditions() { assert(Term->isConditional()); + Value *Default = (Parent == LoopEnd) ? BoolTrue : BoolFalse; + PhiInserter.Initialize(Boolean, ""); - if (Parent == LoopEnd) { + PhiInserter.AddAvailableValue(&Func->getEntryBlock(), Default); + if (Parent == LoopEnd) PhiInserter.AddAvailableValue(LoopStart, BoolTrue); - } else { - PhiInserter.AddAvailableValue(&Func->getEntryBlock(), BoolFalse); + else PhiInserter.AddAvailableValue(Parent, BoolFalse); - } - bool ParentHasValue = false; BasicBlock *Succ = Term->getSuccessor(0); BBPredicates &Preds = (Parent == LoopEnd) ? LoopPred : Predicates[Succ]; + + NearestCommonDominator Dominator(DT); + Dominator.addBlock(Parent, false); + + Value *ParentValue = 0; for (BBPredicates::iterator PI = Preds.begin(), PE = Preds.end(); PI != PE; ++PI) { + if (PI->first == Parent) { + ParentValue = PI->second; + break; + } PhiInserter.AddAvailableValue(PI->first, PI->second); - ParentHasValue |= PI->first == Parent; + Dominator.addBlock(PI->first); } - if (ParentHasValue) - Term->setCondition(PhiInserter.GetValueAtEndOfBlock(Parent)); - else + if (ParentValue) { + Term->setCondition(ParentValue); + } else { + if (!Dominator.wasResultExplicitMentioned()) + PhiInserter.AddAvailableValue(Dominator.getResult(), Default); + Term->setCondition(PhiInserter.GetValueInMiddleOfBlock(Parent)); + } } } |