[PATCH] D147662: [LoopPredication] Fix where we generate widened condition. PR61963

Anna Thomas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 6 12:31:00 PDT 2023


anna added a comment.

In D147662#4249473 <https://reviews.llvm.org/D147662#4249473>, @apilipenko wrote:

> Given that it's the second time we have to fix a similar issue, we should make a common utility for widening that makes it impossible to emit a widened condition in an incorrect context.

Yep, I think it works naturally with the guard widening fix as well. One thing though - this does not prevent from directly identifying an incorrect context unless the utility is used (in short, a verifier would be best).

Also, we should add asserts at two utilities in GuardUtils: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Utils/GuardUtils.cpp#L82

1. setWidenableBranchCond(BranchInst *WidenableBR, Value *NewCond)
2. widenWidenableBranch(BranchInst *WidenableBR, Value *NewCond)

Assert that we didn't convert a loop-invariant `WidenableBR` into a loop-variant one. We add an optional `LI` to this API,  but `LI` is available in both these passes which use the utilities. Will try this out.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147662/new/

https://reviews.llvm.org/D147662



More information about the llvm-commits mailing list