R600/structurizer: improve PHI value finding
authorChristian Konig <christian.koenig@amd.com>
Sat, 16 Feb 2013 11:27:35 +0000 (11:27 +0000)
committerChristian Konig <christian.koenig@amd.com>
Sat, 16 Feb 2013 11:27:35 +0000 (11:27 +0000)
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>
llvm-svn: 175346

llvm/lib/Target/R600/AMDGPUStructurizeCFG.cpp

index 86cb04a..3801347 100644 (file)
@@ -533,12 +533,18 @@ void AMDGPUStructurizeCFG::setPhiValues() {
       Updater.AddAvailableValue(&Func->getEntryBlock(), Undef);
       Updater.AddAvailableValue(To, Undef);
 
+      NearestCommonDominator Dominator(DT);
+      Dominator.addBlock(To, false);
       for (BBValueVector::iterator VI = PI->second.begin(),
            VE = PI->second.end(); VI != VE; ++VI) {
 
         Updater.AddAvailableValue(VI->first, VI->second);
+        Dominator.addBlock(VI->first);
       }
 
+      if (!Dominator.wasResultExplicitMentioned())
+        Updater.AddAvailableValue(Dominator.getResult(), Undef);
+
       for (BBVector::iterator FI = From.begin(), FE = From.end();
            FI != FE; ++FI) {