[PATCH] D116276: [IndVarS] Keep the nsw/nuw flags after simplifyAndExtend

guopeilin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 24 17:49:57 PST 2021


guopeilin added a comment.

With the help of `nsw` flag in `keep-nsw-nuw-flag.ll`, this loop which cannot be vectorized due to `CouldNotCompute BackedgeTakenCount` now can be vectorized.
We can use `opt -indvars keep-nsw-nuw-flag.ll -S | opt -loop-vectorize -S` to verify this.
Also, if we just use `-indvars -loop-vectorize` back to back, this loop can be vectorized without this patch. And I found out that the reason is that `nsw` flag still remains when we try to vectorize this loop. That is some cached value is reused during scalar-evolution analysis for loop-vectorize pass.
During the pipeline, we may call `forgetLoop` in many places, thus the cached value may be cleared. So I guess it is better to keep the `nsw` or `nuw` flags explicitly after widen IV.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116276



More information about the llvm-commits mailing list