[PATCH] D76228: [ValueTracking] Use Inst::comesBefore in isValidAssumeForCtx (NFC).
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 18 10:20:24 PDT 2020
nikic added inline comments.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:602
+ // in the BB.
+ if (Inv->comesBefore(CxtI))
+ return true;
----------------
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...
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76228/new/
https://reviews.llvm.org/D76228
More information about the llvm-commits
mailing list