This is an archive of the discontinued LLVM Phabricator instance.

[X86] Bring back the MOV64r0 pseudo instruction
ClosedPublic

Authored by craig.topper on Oct 1 2018, 5:08 PM.

Details

Summary

This patch brings back the MOV64r0 pseudo instruction for zeroing a 64-bit register. This replaces the SUBREG_TO_REG MOV32r0 sequence we use today. Post register allocation we will rewrite the MOV64r0 to a 32-bit xor with an implicit def of the 64-bit register similar to what we do for the various XMM/YMM/ZMM zeroing pseudos.

My main motivation is to enable the spill optimization in foldMemoryOperandImpl. As we were seeing some code that repeatedly did "xor eax, eax; store eax;" to spill several registers with a new xor for each store. With this optimization enabled we get a store of a 0 immediate instead of an xor. Though I admit the ideal solution would be one xor where there are multiple spills. I don't believe we have a test case that shows this optimization in here. I'll see if I can try to reduce one from the code were looking at.

There's definitely some other machine CSE(and maybe other passes) behavior changes exposed by this patch. So it seems like there might be some other deficiencies in SUBREG_TO_REG handling.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Oct 1 2018, 5:08 PM

Rebase and add spill-zero-x86_64.ll to cover the stack spill case that originally prompted me to look at this. I've reduced this from a complex function that has something like 20 spills of 0 in it. This is the best I was able to reduce it. We don't seem to have any directed tests for spill a 32-bit zero either. It seems to happen in a half dozen or so larger tests.

Update the fast-isel code in MaterializeInt as well

RKSimon accepted this revision.Oct 24 2018, 2:28 AM

LGTM

This revision is now accepted and ready to land.Oct 24 2018, 2:28 AM
This revision was automatically updated to reflect the committed changes.