[llvm] [Uniformity] Fixed control-div early stop (PR #139667)

Sameer Sahasrabuddhe via llvm-commits llvm-commits at lists.llvm.org
Fri May 16 08:12:46 PDT 2025


ssahasra wrote:

What I have in mind is something like this:

```
      // Early stopping criterion
      int DivTermIdx = CyclePOT.getIndex(&DivTermBlock);
      const auto *ImmPDom = getIPDom(&DivTermBlock);
      int FloorIdx = CyclePOT.getIndex(ImmPDom);
      LLVM_DEBUG(dbgs() << "IPDom " << Context.print(ImmPDom)
                 << "with index " << FloorIdx << "\n");

      CycleT *CommonCycle = CI.getSmallestCommonCycle(&DivTermBlock, ImmPDom);
      if (CommonCycle)
        FloorIdx = std::min<int>(FloorIdx, CyclePOT.getIndex(CommonCycle->getHeader()));
      LLVM_DEBUG(dbgs() << "FloorIdx: " << FloorIdx << "\n");
```

Then eliminate all the logic for updating FloorIdx, because we already know the minimum, and do the usual traversal that visits all newly labelled blocks such that `BlockIdx < FloorIdx`.

https://github.com/llvm/llvm-project/pull/139667


More information about the llvm-commits mailing list