[PATCH] D114185: [SCEV] Leverage inferred no-self-wrap flags to refine trip counts

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 22 16:22:54 PST 2021


reames added a comment.

In D114185#3143327 <https://reviews.llvm.org/D114185#3143327>, @nikic wrote:

> I'm really uncomfortable with removing things from UniqueSCEVs. If I understood correctly, your motivation here is that getZeroExtendExpr will not try folds if it has already memoized that the fact that this expression doesn't fold. I think we'd be better off adding a parameter to skip that check for this use-site.

Fair enough, that's why I asked.  Will restructure.

> Though I'm generally starting to have doubts about the direction of the whole patch stack (starting D103991 <https://reviews.llvm.org/D103991>). I find this kind of after the fact fixup of SCEVs rather problematic. Just the additional nowrap flags inferred during zext/sext construction can already cause hard to understand "spooky action at a distance", and this takes things one step further. I didn't really appreciate that this is where this is going.

Yeah, the problem is that "spooky action at a distance" is pretty fundamental to the interaction of trip count logic and SCEV construction.  I could move this into the SCEV construction, but then we have to add a really nasty "is this scev directly used by exit test?" piece.

I have to admit I'm not really a fan of this myself, but I *really* don't see any better options.  I've tried - like *really* tried, this is what resulted in the whole misadventure in indvars - but so far, I have absolutely nothing better.  If you want to brainstorm, I'm happy to see if we can come up with anything better, but after a lot of thought, I've concluded this is the "least bad" place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114185



More information about the llvm-commits mailing list