[PATCH] D105031: [SLP]Fix non-determinism in PHI sorting.

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 18 22:23:15 PDT 2021


skatkov added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:8371
           if (auto *I2 = dyn_cast<Instruction>(Opcodes2[I])) {
-            if (I1->getParent() < I2->getParent())
-              return true;
-            if (I1->getParent() > I2->getParent())
-              return false;
+            DomTreeNodeBase<BasicBlock> *NodeI1 = DT->getNode(I1->getParent());
+            DomTreeNodeBase<BasicBlock> *NodeI2 = DT->getNode(I2->getParent());
----------------
Please note that we met triggering this assert. The reduced by bugpoint reproducer looks as follows:

```
define void @bar() {
bb:
  %tmp = load atomic i8*, i8** undef unordered, align 8
  br label %bb6

bb5:                                              ; No predecessors!
  %tmp4 = load atomic i8*, i8** undef unordered, align 8
  br label %bb6

bb6:                                              ; preds = %bb5, %bb
  %tmp7 = phi i8* [ %tmp, %bb5 ], [ undef, %bb ]
  %tmp8 = phi i8* [ %tmp4, %bb5 ], [ undef, %bb ]
  ret void
}
```
It looks like we can reach this code with unreachable instruction and it is not guarded in optimization.

Could you please fix it or revert the patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105031/new/

https://reviews.llvm.org/D105031



More information about the llvm-commits mailing list