[PATCH] D132443: [LSR] Fold terminating condition to other IV when possible

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 11:16:27 PST 2023


reames added a comment.

I recently stumbled into a test case which would benefit from this, and as a result, took a close look at the code in tree.

I posted one generalization https://reviews.llvm.org/D142240 so that this covers my case of interest.

However, I also think we've got a couple of correctness issues here which need addressed.

First, I don't see anything in the code which checks that the alternate IV is at least as wide as the starting IV.  As a result, we can try to rewrite a loop with a BE count of say 1024 to use an IV which is an i8.  This can change the BE count of the loop.

Second, we're adding a use to an existing IV.  When doing that, we need to worry about about poison correctness.  The case to consider is the alternate IV overflowing on the last iteration, and that poison value previously being unused (since we don't take backedge), and now used in the latch test (resulting in UB).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132443



More information about the llvm-commits mailing list