ソースを参照

Fix scalarizer for shuffle on vector produced later (#1128)

Tex Riddell 7 年 前
コミット
dcaad9e14c
1 ファイル変更10 行追加0 行削除
  1. 10 0
      lib/Transforms/Scalar/Scalarizer.cpp

+ 10 - 0
lib/Transforms/Scalar/Scalarizer.cpp

@@ -576,6 +576,16 @@ bool Scalarizer::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
       Res[I] = Op0[Selector];
       Res[I] = Op0[Selector];
     else
     else
       Res[I] = Op1[Selector - Op0.size()];
       Res[I] = Op1[Selector - Op0.size()];
+    // HLSL Change Begins: (fix bug in upstream llvm)
+    if (ExtractElementInst *EA = dyn_cast<ExtractElementInst>(Res[I])) {
+      // Clone extractelement here, since it is associated with another inst.
+      // Otherwise it will be added to our Gather, and after the incoming
+      // instruction is processed, it will be replaced without updating our
+      // Gather entry.  This dead instruction will be accessed by finish(),
+      // causing assert or crash.
+      Res[I] = IRBuilder<>(SVI.getNextNode()).Insert(EA->clone());
+    }
+    // HLSL Change Ends
   }
   }
   gather(&SVI, Res);
   gather(&SVI, Res);
   return true;
   return true;