[PATCH] D32407: [JumpThread] Do RAUW in case Cond folds to a constant in the CFG

Xin Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 24 19:53:44 PDT 2017


trentxintong added inline comments.


================
Comment at: lib/Transforms/Scalar/JumpThreading.cpp:1322
       // erase it.
       auto *CondInst = dyn_cast<Instruction>(Cond);
       if (CondInst && CondInst->use_empty())
----------------
sanjoy wrote:
> 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.
Good catch with the extra check !


https://reviews.llvm.org/D32407





More information about the llvm-commits mailing list