[PATCH] D87882: [AMDGPU] Fix merging m0 inits

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 09:40:55 PDT 2020


rampitec added a comment.

In D87882#2287724 <https://reviews.llvm.org/D87882#2287724>, @piotr wrote:

>   bb.1:
>     ..
>     TO_inst   (inits m0)
>     ...       (uses m0)
>     FROM_inst (clobbers m0)
>     ...
>     S_CBRANCH_VCCZ %bb.1, undef
>     S_BRANCH %bb.2
>
> I guess I am missing something here, the dominance usually refers to blocks so it can be confusing if applied for instructions.
>
> In this case I expect MDT.dominates(FROM_inst, TO_inst) to return false, because it is possible for a program invocation to execute TO_inst, without executing FROM_inst first (e.g. single loop iteration).
>
> Anyway, the spirit of the code I am editing was that before my patch it was assumed that if FROM_inst comes after TO_inst in a basic block (as in the case described above) then there was no path from FROM_inst to TO_inst, so TO_inst could be removed. This is not true for loops, where FROM_inst will clober m0 used in the next iteration.

If block A dominates block B then all instructions in A dominate all instructions in B, isn't it? That is not changed if A == B. Imagine you have split that block in between of "From" and "To" and there is simple fall-through at that split. Nothing has changed in the program logic, right? But now MDT::dominates() suddenly start to return true instead of false. This just cannot be right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87882



More information about the llvm-commits mailing list