[PATCH] D146429: [LSR] Fix wrapping bug in lsr-term-fold logic

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 20 11:24:30 PDT 2023


reames added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6789
+    if (NoOverflowBitWidth > ARBitWidth)
+      return nullptr;
+
----------------
nikic wrote:
> Hm, can't we do something like check the nowrap (as in `<nw>`) flag on the post-inc addrec here?
I think you might be on to something here.  Let me give this a bit more thought and see if I can find a counter example.


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:6799
                     AddRec->getOperand(1)->getType())),
             AddRec->getOperand(0)->getType()));
     const DataLayout &DL = L->getHeader()->getModule()->getDataLayout();
----------------
nikic wrote:
> Side note, but this code looks like `evaluateAtIteration()`.
I'd noticed that too, I'm just trying to fix this code one bit at a time.  It also looks somewhat like LFTR's genLoopLimit and I have yet dug into the three enough to be really sure they compute the same values under all edge cases.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146429



More information about the llvm-commits mailing list