[PATCH] D81301: [X86] Emit two-byte NOP when possible

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 5 15:10:59 PDT 2020


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/X86/X86MCInstLower.cpp:1102
+    if (Subtarget->is32Bit() && NumBytes >= 2) {
+      OS.emitInstruction(
+          MCInstBuilder(X86::XCHG16ar).addReg(X86::AX).addReg(X86::AX),
----------------
craig.topper wrote:
> efriedma wrote:
> > MaskRay wrote:
> > > Can the x86-64 code path below be reused?
> > I see three issues with using the 64-bit codepath on 32-bit:
> > 
> > 1. We can't use the patterns based on REX prefixes.
> > 2. The X86::NOOPL opcode requires FeatureNOPL.
> > 3. If Mode16Bit is enabled, XCHG16ar is actually a one-byte instruction.
> > 
> > So we could sort of reuse the code below, but it would require a lot of refactoring.
> Can Mode16Bit be set here? We're coming from MachineInstr and we don't compile to 16 bit do we?
> 
> The only part in the reset of the code that is truly 64-bit specific is the IndexReg being RAX. There's nothing in there that requiers a REX prefix.
> 
> So it seems like we just need to replace the Is64Bit check we had before with FeatureNOPL and then pick the index register as RAX or EAX depending on 64 bit or 32 bit.
I guess we'd still need to handle the case where the CPU was set to a 386/486/pentium where FeatureNOPL isn't set.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81301/new/

https://reviews.llvm.org/D81301





More information about the llvm-commits mailing list