[llvm] [llvm-exegesis] Align loop MBB in loop repetitor (PR #77264)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 7 18:29:26 PST 2024
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/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.
>From 68995cfffc153c824d68ada531ddf8b7cc94daab Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Sun, 7 Jan 2024 17:42:39 -0800
Subject: [PATCH] [llvm-exegesis] Align loop MBB in loop repetitor
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.
---
llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp b/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp
index cc5a045a8be5dd..2e23351de8e0dc 100644
--- a/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp
+++ b/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp
@@ -74,6 +74,10 @@ class LoopSnippetRepetitor : public SnippetRepetitor {
auto Loop = Filler.addBasicBlock();
auto Exit = Filler.addBasicBlock();
+ // Align the loop machine basic block to a sixteen byte boundary
+ // so that instruction fetch on modern x86 platforms works optimally.
+ Loop.MBB->setAlignment(Align(16));
+
const unsigned LoopUnrollFactor =
LoopBodySize <= Instructions.size()
? 1
More information about the llvm-commits
mailing list