This is an archive of the discontinued LLVM Phabricator instance.

[x86] Improve selection of the mov instruction in FrameLowering
Needs ReviewPublic

Authored by nagisa on Mar 21 2021, 5:29 PM.

Details

Summary

MOV64ri results in a significantly longer encoding, and use of this operator is fairly avoidable as
we can always check the size of the immediate we're using.

Diff Detail

Event Timeline

nagisa created this revision.Mar 21 2021, 5:29 PM
nagisa published this revision for review.Apr 1 2021, 4:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2021, 4:03 PM

Happy to pre-commit the tests if this is something that we actually want to do.

craig.topper added inline comments.
llvm/lib/Target/X86/X86FrameLowering.cpp
154

You also do

if (isUInt<32>(Imm))
  return MOV32ri64;

It's weirdly named but it's load a 32 bit immediate into the lower 32 bits and zero extend. Should avoid a REX prefix I think.

157

You can drop this else since the if returned.

llvm/test/CodeGen/X86/segmented-stacks-dynamic.ll
2

Can you pretend you pre-commited the test for the purposes of this diff so it's readable?

rnk added a comment.Apr 2 2021, 11:01 AM

Seems reasonable

llvm/lib/Target/X86/X86FrameLowering.cpp
253

Offset here is always >2GB, so this is NFC, but still a simplification.

llvm/test/CodeGen/X86/segmented-stacks-dynamic.ll