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

Alexandre Isoard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 20 10:14:05 PDT 2018


alexandre.isoard added a comment.

In https://reviews.llvm.org/D48338#1137890, @timshen wrote:

> What about `zext(%a + %b) + %c`? I think `zext(%a) + zext(%b) + %c` is in a much better state than, idk, `zext(%a + %b + trunc(%c))`.


I don't think those transformations are legal in the general case. But I would go for the expression that has the minimum bit-width of operators in general (that is, sink `trunc` but lift `sext` and `zext`).
Could you explain why your form is preferable (you may have good reasons I am missing)? I have a feeling the true issue is that we have trouble manipulating `zext`/`sext`/`trunc` and that is probably why we have some heuristic to not duplicate them too much.

I have a patch that improve the mobility of those on AddExpr, but I am not 100% sure of its correctness.

It transforms: `(sext i57 (199 * (trunc i64 (-1 + (2780916192016515319 * %n)) to i57)) to i64)` into `(sext i57 (-199 + (trunc i64 %n to i57)) to i64)` (not sure if that is correct).

Would that go towards your goal?


https://reviews.llvm.org/D48338





More information about the llvm-commits mailing list