[all-commits] [llvm/llvm-project] b95214: [LSR] Rewrite IV match for term-fold using existin...

Philip Reames via All-commits all-commits at lists.llvm.org
Mon Mar 20 10:41:16 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b9521484ec72142bce8124a171206fc577abfd3f
  Author: Philip Reames <preames at rivosinc.com>
  Date:   2023-03-20 (Mon, 20 Mar 2023)

  Changed paths:
    M llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    M llvm/test/Transforms/LoopStrengthReduce/lsr-term-fold-negative-testcase.ll
    M llvm/test/Transforms/LoopStrengthReduce/lsr-term-fold.ll

  Log Message:
  [LSR] Rewrite IV match for term-fold using existing utilities

Main benefit here is making the logic easier to follow, slightly more efficient, and more in line with LFTR.  This is not NFC.  There are three semantic changes here.

First, we drop handling for constants on the LHS of the comparison.  These are non-canonical, and we're very late in the optimization pipeline here, so there's no point in supporting this.  I removed a test which covered this case.

Second, we don't need the almost dead IV to be an addrec.  We just need SCEV to be able to compute a trip count for it.

Third, we require a simple IV for the almost dead IV.  In theory, this removes cases we could have previously handled, but given a) zero testing and b) multiple known correctness issues, I'm adopting an attidute of narrowing this down to something which works correctly, and *then* expanding.

More information about the All-commits mailing list