[llvm] 7173ae9 - [llvm-exegesis] Align loop MBB in loop repetitor (#77264)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 8 11:51:24 PST 2024
Author: Aiden Grossman
Date: 2024-01-08T11:51:20-08:00
New Revision: 7173ae99c0e1b13536a8492335c595f8aaee4267
URL: https://github.com/llvm/llvm-project/commit/7173ae99c0e1b13536a8492335c595f8aaee4267
DIFF: https://github.com/llvm/llvm-project/commit/7173ae99c0e1b13536a8492335c595f8aaee4267.diff
LOG: [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.
Added:
Modified:
llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp b/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp
index cc5a045a8be5dd..1872f550c3f310 100644
--- a/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp
+++ b/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp
@@ -10,6 +10,7 @@
#include "Target.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
+#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
namespace llvm {
@@ -74,6 +75,11 @@ class LoopSnippetRepetitor : public SnippetRepetitor {
auto Loop = Filler.addBasicBlock();
auto Exit = Filler.addBasicBlock();
+ // Align the loop machine basic block to a target-specific boundary
+ // to promote optimal instruction fetch/predecoding conditions.
+ Loop.MBB->setAlignment(
+ Filler.MF.getSubtarget().getTargetLowering()->getPrefLoopAlignment());
+
const unsigned LoopUnrollFactor =
LoopBodySize <= Instructions.size()
? 1
More information about the llvm-commits
mailing list