This is an archive of the discontinued LLVM Phabricator instance.

Properly handle PHIs with subregisters in UnreachableBlockElim
ClosedPublic

Authored by kparzysz on Apr 28 2017, 10:52 AM.

Details

Summary

When a PHI operand has a subregister, create a COPY into a new register instead of simply replacing the PHI output with it.

Diff Detail

Repository
rL LLVM

Event Timeline

kparzysz created this revision.Apr 28 2017, 10:52 AM
kparzysz updated this revision to Diff 97126.Apr 28 2017, 10:54 AM

Moved the phi deletion into the correct place.

MatzeB added inline comments.Apr 28 2017, 11:07 AM
lib/CodeGen/UnreachableBlockElim.cpp
208 ↗(On Diff #97126)

Maybe add an assert(Output.getSubReg() == 0); just to document that we do not write subregisters with Phis.

213–221 ↗(On Diff #97126)

Why go through the trouble of creating a new output register? You should be able to reuse "OutputReg" and not do any replaceRegWith operation.

test/CodeGen/Hexagon/unreachable-mbb-phi-subreg.mir
3–7 ↗(On Diff #97126)

You can remove the whole IR block in this case.

21 ↗(On Diff #97126)

And there's this new cool syntax (the MIPrinter just doesn't know how to use it yet), where you can do

%0 : doubleregs = COPY %d0
...
%1 : intregs = PHI ...

instead of using a registers: block.

kparzysz marked 3 inline comments as done.Apr 28 2017, 11:22 AM
kparzysz added inline comments.
lib/CodeGen/UnreachableBlockElim.cpp
213–221 ↗(On Diff #97126)

Ha, indeed.

kparzysz updated this revision to Diff 97129.Apr 28 2017, 11:23 AM
kparzysz marked an inline comment as done.

Don't create unnecessary registers, use shorter mir syntax.

kparzysz updated this revision to Diff 97130.Apr 28 2017, 11:27 AM
kparzysz marked an inline comment as done.

Remove the LLVM IR from the mir testcase.

MatzeB accepted this revision.Apr 28 2017, 12:29 PM

LGTM.

This revision is now accepted and ready to land.Apr 28 2017, 12:29 PM
This revision was automatically updated to reflect the committed changes.