[PATCH] D97667: [loop-idiom] Hoist loop memcpys to loop preheader

Han Zhu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 30 15:26:47 PDT 2021


zhuhan0 marked an inline comment as done.
zhuhan0 added a comment.

In D97667#2724992 <https://reviews.llvm.org/D97667#2724992>, @tpopp wrote:

> Describing what the code is intended to do (https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/xla/tests/reverse_test.cc#L146).
>
> A 4d array is taking in reversing elements across the 0th and 1st dimensions, so for every value previously indexed at [A,B,C,D] in an array of size [W,X,Y,Z], the new index of the value is [W-A-1, X-B-1, C, D].
>
> The original code indexes into proper locations for the first 2 dimensions, and then copies the subdata, while this change results in a single copy after indexing only in dimension 0, which cannot be done as the data in dimension 1 cannot be copied due to the reversal.

Makes sense. Thanks for the IR and explanation.

@lebedev.ri pointed out the issue earlier and I fixed it in the newest version. I ran `opt -S -loop-diom` on the IR you provided and it does not hoist the memcpy anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97667



More information about the llvm-commits mailing list