[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
Wed Jun 20 18:44:10 PDT 2018


timshen added a comment.

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

> That might be related, for instance, such expressions:
>
>   ((zext i3 {0,+,1}<%bb> to i64) + (8 * ({0,+,1}<nuw><nsw><%bb> /u 8)) + %a)
>   
>
> get simplified into:
>
>   {%a,+,1}<nw><%bb>


I don't see the pattern I'm trying to match.

Though I can't easily reduce to a test case, the code I'm specifically looking at looks like the following:

  %11 = udiv i32 %10, 112
  %12 = mul i32 %11, 112
  %13 = sub i32 %10, %12
  %14 = urem i32 %11, 112
  %15 = udiv i32 %10, 12544
  %16 = zext i32 %15 to i64
  %17 = zext i32 %14 to i64
  %18 = zext i32 %13 to i64
  %19 = getelementptr inbounds [128 x [112 x [112 x [64 x float]]]], [128 x [112 x [112 x [64 x float]]]] addrspace(1)* %ptr, i64 0, i64 %16, i64 %17, i64 %18, i64 %3

The idea is that %10 is a flat index of %ptr, and the whole GEP should be equivalent to (in C) `&%ptr[%10]`. This already works for a case where there is no zexts and everything is i32. This patch makes it work with zexts.


https://reviews.llvm.org/D48338





More information about the llvm-commits mailing list