- The current implementation simplifies the case where the source of copyto is implicit-defed. However, it only works when that implicit-def is single-used since it detects that from implicit-def and cannot determine which destination vreg should be used if there are multiple uses.
- This patch changes that detection when copyto is being emitted. If that copyto's source is defined from implicit-def, it simplifies it. Hence, it works even that implicit-def is multi-used.
- Except it simplifies the internal IR, it won't improve the quality of code generation. However, it helps to detect 'implicit-def` in a straight-forward manner in some passes, such as si-i1-copies. A test case is added.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I don't think this is correct. If an IMPLICIT_DEF has multiple uses, then the correctness of the program may depend on all uses seeing the same value, even if that value is undefined.
The description also doesn't line up with the test description (which talks about making sure that something doesn't crash).
IMPLICIT_DEF is multi-instantiated in lowering, i.e. each use of it has a dedicated definition of IMPLICIT_DEF (refer to getVR and getDstOfOnlyCopyToRegUse). The only slight simplification is for the sequence of COPY_TO followed by IMPLICIT_DEF on virtual register dest. In that case, that COPY_TO could be eliminated. IMPLICIT_DEF is just undef, the implementation has the right to decide how to do it efficiently.
I don't think this is a guaranteed property. This is the MIR equivalent of the poison/freeze question, but today implicit_def doesn't give you this
llvm/test/CodeGen/AMDGPU/i1-copy-phi.ll | ||
---|---|---|
41–42 ↗ | (On Diff #201125) | This should check something. I also suspect it can be reduced further |
llvm/test/CodeGen/AMDGPU/i1-copy-phi.ll | ||
---|---|---|
41–42 ↗ | (On Diff #201125) | test is reduced |