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.

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.

Interesting...

Tim, thank you for explanation.

Thank you,
Serguei.