Browse Source

Revert "Skip inserting redundant phi nodes on struct type (#1748)" (#1755)

This reverts commit 545bf5e0c5527a7e904e4a559ad3c4f99cc610cb.
Vishal Sharma 6 years ago
parent
commit
ff7deb40d2

+ 1 - 12
lib/Transforms/Utils/LCSSA.cpp

@@ -215,7 +215,6 @@ blockDominatesAnExit(BasicBlock *BB,
 bool llvm::formLCSSA(Loop &L, DominatorTree &DT, LoopInfo *LI,
                      ScalarEvolution *SE) {
   bool Changed = false;
-  bool shouldExpectLCSSAform = true;
 
   // Get the set of exiting blocks.
   SmallVector<BasicBlock *, 8> ExitBlocks;
@@ -246,15 +245,6 @@ bool llvm::formLCSSA(Loop &L, DominatorTree &DT, LoopInfo *LI,
            !isa<PHINode>(I->user_back())))
         continue;
 
-      // HLSL changes begin
-      // Skip inserting redundant PHI nodes on instruction of struct type
-      // as the resultant IR is not considered a valid DXIL.
-      if (I->getType()->isStructTy()) {
-        shouldExpectLCSSAform = false;
-        continue;
-      }
-      // HLSL changes end
-
       Changed |= processInstruction(L, *I, DT, ExitBlocks, PredCache, LI);
     }
   }
@@ -265,8 +255,7 @@ bool llvm::formLCSSA(Loop &L, DominatorTree &DT, LoopInfo *LI,
   if (SE && Changed)
     SE->forgetLoop(&L);
 
-  if(shouldExpectLCSSAform)
-    assert(L.isLCSSAForm(DT));
+  assert(L.isLCSSAForm(DT));
 
   return Changed;
 }

+ 0 - 76
tools/clang/test/CodeGenHLSL/nolcssa-on-struct-type.hlsl

@@ -1,76 +0,0 @@
-// RUN: %dxc -E main -T ps_6_0 /Zpr /O3 %s | FileCheck %s
-// CHECK-NOT: phi %dx.types.CBufRet.i32
-
-cbuffer cb
-{
- int cb_a;
- int cb_b;
- bool cb_c[1];
-}
-
-static const struct
-{
- int a;
- int b;
- bool c[1];
-} cbstruct = { cb_a, cb_b, cb_c };
-
-
-bool IsPos( float3 pos )
-{
- float maxpos = max(pos.x, max(pos.y, pos.z) );
- float minpos = min(pos.x, min(pos.y, pos.z) );
- return ( maxpos < 32 && minpos > 0 );
-}
-
-float3 GetPos()
-{
- [branch]
- if(cbstruct.c[cbstruct.b])
- {
-  return float3(0,0,0);
- }
- else
- {
-  return float3(1,1,1);
- }
-}
-
-int GetIdx( )
-{
- for( int i=0; i< 4 ; i++ )
- {
-  if( i == cbstruct.b )
-  {
-   return -1;
-  }
-  float3 pos = GetPos();
-  if( IsPos(pos) )
-  {
-   return i;
-  }
- }
-
- return -1;
-}
-
-float GetColor()
-{
- int idx = GetIdx(); 
- if( idx == cbstruct.a )
- {
-   return 1.0;
- }
- return 0.0;
-}
-
-
-void main(out float4 OutColor : SV_Target0)
-{
- float x = GetColor();
- [branch]
- if ( x < 0.0001f )
- {
-  OutColor = 0.0f;
- }
-}