[PATCH] D80086: [VPlan] Fix bug45985

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 17 10:39:08 PDT 2020


fhahn requested changes to this revision.
fhahn added reviewers: Ayal, gilr.
fhahn added a comment.
This revision now requires changes to proceed.

Thanks for the patch. Could you add a test case for the crash?



================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:4068
+      // Check dominance of NewIncV with NewPredBB.
+      if (Instruction *NewIncI = dyn_cast<Instruction>(NewIncV)) {
+        if (!DT->dominates(NewIncI, NewPredBB)) {
----------------
This seems a bit more complicated than necessary I think

IIUC, if we have a map ScalarPred -> VectorPred (lets call it ScalarPred2VectorPred) we can get the blocks in the loop as follows:

```
BasicBlock *ScalarBB = OrigPhi->getIncomingBlock(i);
BasicBlock *VectorBB = ScalarPred2VectorPred[ScalarBB]; // (also assert that ScalarBB is in the map)
```

Building ScalarPred2VectorPred should be straight-forward IIUC, as we should be able to rely on the predecessor order being the same between vector and scalar versions: just set `ScalarPred2VectorPred[ScalarBBPredecessors[I]] = VectorBBPredecessors[I];` You also don't have to ScalarBBPredecessors/VectorBBPredecessors directly. You can just iterate over the predecessors for both and populate the map (you might want to use llvm::zip from STLExtras.h)


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

https://reviews.llvm.org/D80086





More information about the llvm-commits mailing list