[PATCH] D48338: [SCEV] Improve zext(A /u B) and zext(A % B)

Tim Shen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 19 19:16:34 PDT 2018


timshen added a comment.

In https://reviews.llvm.org/D48338#1137177, @alexandre.isoard wrote:

> I have been working on related issue but my strategy is different:
>
> When we reduce `AddExpr(zext(X), Y, Z)` I ask for `X' = getAnyExtendExpr(X)` (which do not involve any `zext`/`sext`/`trunc` usually and try to look for a matching `(A*X'/A)` in `Y` or `Z`.
>  If I find it, then I replace the `zext(X)` by `X'` and remove the matching `(A*X'/A)`.
>  That is, it is equivalent to replace `zext(X)` by `X'-(X'/A*A)` and have the subtract part cancel out with one of the other element of the addition.


In my use case, the zext is introduced by LLVM IR. In that case, ScalarEvolution::createSCEV will just call getZeroExtendExpr. I'm not sure if we can use getAnyExtendExpr there.


https://reviews.llvm.org/D48338





More information about the llvm-commits mailing list