This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fix multiple vreg definitions in si-lower-control-flow
ClosedPublic

Authored by rampitec on Nov 21 2016, 2:56 PM.

Details

Summary

SI Lower control flow pass creates multiple definitions of virtual registers.

SI_IF:

%vreg3<def> = COPY %EXEC, %EXEC<imp-def>; SReg_64:%vreg3
%vreg47<def> = S_AND_B64 %vreg3, %vreg20, %SCC<imp-def,dead>; SReg_64:%vreg47,%vreg3,%vreg20
%vreg3<def> = S_XOR_B64 %vreg47, %vreg3, %SCC<imp-def,dead>; SReg_64:%vreg3,%vreg47

SI_ELSE:

%vreg2<def> = COPY %vreg0<kill>; SReg_64:%vreg2,%vreg0
%vreg2<def> = S_OR_SAVEEXEC_B64 %vreg2, %EXEC<imp-def>, %SCC<imp-def>, %EXEC<imp-use>; SReg_64:%vreg2
%vreg1<def> = COPY %vreg20<kill>; VGPR_32:%vreg1,%vreg20
%EXEC<def> = S_AND_B64 %EXEC, %vreg19<kill>, %SCC<imp-def,dead>; SReg_64:%vreg19
%vreg21<def> = COPY %vreg1<kill>; VGPR_32:%vreg21,%vreg1
%vreg2<def> = S_AND_B64 %EXEC, %vreg2, %SCC<imp-def>; SReg_64:%vreg2
%EXEC<def> = S_XOR_B64_term %EXEC, %vreg2; SReg_64:%vreg2

This is the patch to fix SSA.

Diff Detail

Repository
rL LLVM

Event Timeline

rampitec updated this revision to Diff 78788.Nov 21 2016, 2:56 PM
rampitec retitled this revision from to [AMDGPU] Fix multiple vreg definitions in si-lower-control-flow.
rampitec updated this object.
rampitec added reviewers: arsenm, nhaehnle.
rampitec set the repository for this revision to rL LLVM.
rampitec added a subscriber: llvm-commits.
arsenm edited edge metadata.Nov 21 2016, 4:55 PM

Do you have a testcase where this was an issue? I though I got all of these when I moved the pass to SSA. Why isn't the verifier catching this?

Do you have a testcase where this was an issue? I though I got all of these when I moved the pass to SSA. Why isn't the verifier catching this?

Technically pass works post SSA, so it is not required to maintain SSA. It does not create errors (at least I'm not aware of errors caused by this), but results in MRI->getUniqueVRegDef() returning a null pointer. I'm working on combining two S_AND_B64 instructions in the snippet below and similar, and it if returns nullptr my code simply cannot do anything.

%vreg20<def> = S_AND_B64 %EXEC, %vreg18, %SCC<imp-def,dead>; SReg_64:%vreg20,%vreg18
%vreg46<def> = COPY %vreg19<kill>; VGPR_32:%vreg46,%vreg19
%vreg3<def> = COPY %EXEC, %EXEC<imp-def>; SReg_64:%vreg3
%vreg47<def> = S_AND_B64 %vreg3, %vreg20, %SCC<imp-def,dead>; SReg_64:%vreg47,%vreg3,%vreg20
%vreg3<def> = S_XOR_B64 %vreg47, %vreg3, %SCC<imp-def,dead>; SReg_64:%vreg3,%vreg47
arsenm accepted this revision.Nov 21 2016, 5:30 PM
arsenm edited edge metadata.

Oh right I forgot I moved it to SSA and then back. LGTM assuming tests pass, I thought there was some pain for maintaining live intervals without re-using

This revision is now accepted and ready to land.Nov 21 2016, 5:30 PM
This revision was automatically updated to reflect the committed changes.