This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Fold spills of COPY of WZR/XZR
ClosedPublic

Authored by gberry on Nov 22 2016, 8:38 AM.

Details

Summary

In AArch64InstrInfo::foldMemoryOperandImpl, catch more cases where the
COPY being spilled is copying from WZR/XZR, but the source register is
not in the COPY destination register's regclass.

For example, when spilling:

%vreg0 = COPY %XZR ; %vreg0:GPR64common

without this change, the code in TargetInstrInfo::foldMemoryOperand()
and canFoldCopy() that normally handles cases like this would fail to
optimize since %XZR is not in GPR64common. So the spill code generated
would be:

%vreg0 = COPY %XZR
STR %vreg

instead of the new code generated:

STR %XZR

Diff Detail

Repository
rL LLVM

Event Timeline

gberry updated this revision to Diff 78881.Nov 22 2016, 8:38 AM
gberry retitled this revision from to [AArch64] Fold spills of COPY of WZR/XZR.
gberry updated this object.
gberry added reviewers: qcolombet, MatzeB.
MatzeB accepted this revision.Nov 28 2016, 12:47 PM
MatzeB edited edge metadata.

I like solving the problem with the spill folding mechanism.
LGTM.

lib/Target/AArch64/AArch64InstrInfo.cpp
2612 ↗(On Diff #78881)

I would use references instead of pointers for things that cannot be nullptr. Similar with TRI, RC below.

This revision is now accepted and ready to land.Nov 28 2016, 12:47 PM
qcolombet accepted this revision.Nov 28 2016, 1:10 PM
qcolombet edited edge metadata.

LGTM as well.

This revision was automatically updated to reflect the committed changes.