[PATCH] D32407: [JumpThread] Do RAUW in case Cond folds to a constant in the CFG
Sanjoy Das via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 24 18:21:26 PDT 2017
sanjoy accepted this revision.
sanjoy added a comment.
This revision is now accepted and ready to land.
lgtm with nits
================
Comment at: lib/Transforms/Scalar/JumpThreading.cpp:1252
BasicBlock *OnlyDest = nullptr;
BasicBlock *MultipleDestSentinel = (BasicBlock*)(intptr_t)~0ULL;
+ Constant *OnlyVal = nullptr;
----------------
Separately, it may be better to use `DenseMapInfo<BasicBlock *>::getTombStoneKey()` here.
================
Comment at: lib/Transforms/Scalar/JumpThreading.cpp:1322
// erase it.
auto *CondInst = dyn_cast<Instruction>(Cond);
if (CondInst && CondInst->use_empty())
----------------
I'd structure this as:
```
if (auto *CondInst = dyn_cast<Instruction>(Cond)) {
if (CondInst->use_empty()) {
} else if (OnlyVal && ...) {
}
}
```
Another thing is that this code needs to check `!CondInst->mayHaveSideEffects()` before removing it.
================
Comment at: test/Transforms/JumpThreading/fold-not-thread.ll:142
+entry:
+ %cmp = icmp eq i32 %value, 32
+ br i1 %cmp, label %L0, label %L3
----------------
Please also add a negative test where `%add = add i32 %value, 64` is not in L0.
https://reviews.llvm.org/D32407
More information about the llvm-commits
mailing list