Serguei Katkov via llvm-dev
2017-Aug-01 08:04 UTC
[llvm-dev] X86PadShortFunction.cpp inserts noops twice
Hi, while taking a look at X86PadShortFunction.cpp I found that /// addPadding - Add the given number of NOOP instructions to the function /// just prior to the return at MBBI void PadShortFunc::addPadding(MachineBasicBlock *MBB, MachineBasicBlock::iterator &MBBI, unsigned int NOOPsToAdd) { DebugLoc DL = MBBI->getDebugLoc(); while (NOOPsToAdd-- > 0) { BuildMI(*MBB, MBBI, DL, TII->get(X86::NOOP)); BuildMI(*MBB, MBBI, DL, TII->get(X86::NOOP)); } What is the reason to add two noops? What am I missing? Thank you, Serguei. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170801/aecb80db/attachment.html>
Tim Northover via llvm-dev
2017-Aug-01 16:36 UTC
[llvm-dev] X86PadShortFunction.cpp inserts noops twice
On 1 August 2017 at 01:04, Serguei Katkov via llvm-dev <llvm-dev at lists.llvm.org> wrote:> What is the reason to add two noops? What am I missing?It does seem to be intentional (looking at the test) so my guess is that it's because the Atom is dual-issue (i.e. executes 2 instructions per cycle). The early part of the calculation and wording of the problem (in r171879) seems to be in cycles and then this code (with the misnamed "NOOPsToAdd") gets called to use up some number of them. Emitting 2 NOPs probably consumes both pipelines for 1 cycle. Cheers. Tim.
Serguei Katkov via llvm-dev
2017-Aug-02 03:31 UTC
[llvm-dev] X86PadShortFunction.cpp inserts noops twice
Interesting... Tim, thank you for explanation. Thank you, Serguei.> -----Original Message----- > From: Tim Northover [mailto:t.p.northover at gmail.com] > Sent: Tuesday, August 1, 2017 11:37 PM > To: Serguei Katkov <serguei.katkov at azul.com> > Cc: llvm-dev <llvm-dev at lists.llvm.org> > Subject: Re: [llvm-dev] X86PadShortFunction.cpp inserts noops twice > > On 1 August 2017 at 01:04, Serguei Katkov via llvm-dev <llvm- > dev at lists.llvm.org> wrote: > > What is the reason to add two noops? What am I missing? > > It does seem to be intentional (looking at the test) so my guess is that it's > because the Atom is dual-issue (i.e. executes 2 instructions per cycle). > > The early part of the calculation and wording of the problem (in > r171879) seems to be in cycles and then this code (with the misnamed > "NOOPsToAdd") gets called to use up some number of them. Emitting 2 > NOPs probably consumes both pipelines for 1 cycle. > > Cheers. > > Tim.