D51664 added Instruction::comesBefore which should provide better
performance than the manual check.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
230 ms | Clang.Analysis::Unknown Unit Message ("") |
Event Timeline
llvm/lib/Analysis/ValueTracking.cpp | ||
---|---|---|
605 | Isn't the !DT condition still relevant here? If we have DT, then this was already covered by the domination check. Generally, I think this code is a bit convoluted, and I think it would be clearer to rewrite along these lines: BasicBlock *InvBB = Inv->getParent(), *CxtBB = CxtI->getParent(); if (InvBB != CxtBB) { if (DT) return DT->dominates(InvBB, CxtBB); else // We don't have a DT, but this trivially dominates. return InvBB == CxtBB->getSinglePredecessor(); } // If Inv and CtxI are in the same block, check if the assume (Inv) is first // in the BB. if (Inv->comesBefore(CxtI)) return true; // Rest of the code... |
Generally, I think this code is a bit convoluted, and I think it would be clearer to rewrite along these lines.
Agreed, I've restructured the code a bit. It seemed a bit more straight forward to check and handle the case were both instructions are in the same BB up front, followed by the DT check. WDYT?
This condition is redundant, it's already checked above.