[PATCH] D143409: [SCEV][IndVarSimplify] Add nsw/nuw falgs to binary ops before visiting IVUsers

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 14 15:16:30 PST 2023


fhahn added a comment.

In D143409#4125832 <https://reviews.llvm.org/D143409#4125832>, @nikic wrote:

> Thanks for the explanation.
>
> In D143409#4125708 <https://reviews.llvm.org/D143409#4125708>, @aleksandr.popov wrote:
>
>> But if we visit bin op firstly and annotate it with nsw/nuw flags, they will be propagated to IV's SCEV:
>
> I suspect that what actually happens is that as part of the getZeroExtendExpr() call, we infer a nowrap flag on the addrec in https://github.com/llvm/llvm-project/blob/7a49d50f22ad577d91cda7904c8a162c2cecd4a8/llvm/lib/Analysis/ScalarEvolution.cpp#L1688, or one of the later bits in the same method. If this is the case, it would be nice to know which one is responsible here, and in particular whether it is the constant range one.
>
> This is a long-standing issue, that nowrap flags are inferred when creating zext/sext expressions, so that creating those expressions can improve "unrelated" analysis results. I tried to address the constant range nowrap inference in D90338 <https://reviews.llvm.org/D90338>, but haven't pursued this in a while.

That reminded me of a patch I had lying around for a while to strengthen no wrap flags when construction AddRecs: D144050 <https://reviews.llvm.org/D144050>


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

https://reviews.llvm.org/D143409



More information about the llvm-commits mailing list