Skip to content

Commit 7173ae9

Browse files
[llvm-exegesis] Align loop MBB in loop repetitor (#77264)
This patch sets the alignment of the loob MBB in the loop repetitor to 16 to avoid instruction fetch/predecoding bottlenecks that can come up with unaligned code. The value of 16 was chosen based on numbers for recent Intel microarchitectures and reccomendations from Agner Fog. Fixes #77259.
1 parent e7655ad commit 7173ae9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "Target.h"
1111
#include "llvm/ADT/Sequence.h"
1212
#include "llvm/CodeGen/TargetInstrInfo.h"
13+
#include "llvm/CodeGen/TargetLowering.h"
1314
#include "llvm/CodeGen/TargetSubtargetInfo.h"
1415

1516
namespace llvm {
@@ -74,6 +75,11 @@ class LoopSnippetRepetitor : public SnippetRepetitor {
7475
auto Loop = Filler.addBasicBlock();
7576
auto Exit = Filler.addBasicBlock();
7677

78+
// Align the loop machine basic block to a target-specific boundary
79+
// to promote optimal instruction fetch/predecoding conditions.
80+
Loop.MBB->setAlignment(
81+
Filler.MF.getSubtarget().getTargetLowering()->getPrefLoopAlignment());
82+
7783
const unsigned LoopUnrollFactor =
7884
LoopBodySize <= Instructions.size()
7985
? 1

0 commit comments

Comments
 (0)