[llvm] Reapply "[llvm-exegesis] Exclude loads/stores from aliasing instruction set" (#156735) (PR #159366)

Sjoerd Meijer via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 17 07:01:54 PDT 2025


https://github.com/sjoerdmeijer created https://github.com/llvm/llvm-project/pull/159366

Move the mayLoad/mayStore checks out of hasMemoryOperands; there are instructions with these properties that don't have operands.

>From ad34447062ccf633b2d60ce6937355a900801a8c Mon Sep 17 00:00:00 2001
From: Sjoerd Meijer <smeijer at nvidia.com>
Date: Mon, 15 Sep 2025 03:44:26 -0700
Subject: [PATCH] Reapply "[llvm-exegesis] Exclude loads/stores from aliasing
 instruction set" (#156735)

Move the mayLoad/mayStore checks out of hasMemoryOperands; there are
instructions with these properties that don't have operands.
---
 .../test/tools/llvm-exegesis/AArch64/no-aliasing-ld-str.s | 8 ++++++++
 llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp   | 6 ++++++
 2 files changed, 14 insertions(+)
 create mode 100644 llvm/test/tools/llvm-exegesis/AArch64/no-aliasing-ld-str.s

diff --git a/llvm/test/tools/llvm-exegesis/AArch64/no-aliasing-ld-str.s b/llvm/test/tools/llvm-exegesis/AArch64/no-aliasing-ld-str.s
new file mode 100644
index 0000000000000..65e1203bb275d
--- /dev/null
+++ b/llvm/test/tools/llvm-exegesis/AArch64/no-aliasing-ld-str.s
@@ -0,0 +1,8 @@
+REQUIRES: aarch64-registered-target
+
+RUN: llvm-exegesis -mtriple=aarch64 -mcpu=neoverse-v2 -mode=latency --dump-object-to-disk=%d --opcode-name=FMOVWSr --benchmark-phase=assemble-measured-code 2>&1
+RUN: llvm-objdump -d %d > %t.s
+RUN: FileCheck %s < %t.s
+
+CHECK-NOT: ld{{[1-4]}}
+CHECK-NOT: st{{[1-4]}}
diff --git a/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp b/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp
index bdfc93e22273b..707e6ee2d434b 100644
--- a/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp
+++ b/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp
@@ -57,6 +57,12 @@ computeAliasingInstructions(const LLVMState &State, const Instruction *Instr,
       continue;
     if (OtherInstr.hasMemoryOperands())
       continue;
+    // Filtering out loads/stores might belong in hasMemoryOperands(), but that
+    // complicates things as there are instructions with may load/store that
+    // don't have operands (e.g. X86's CLUI instruction). So, it's easier to
+    // filter them out here.
+    if (OtherInstr.Description.mayLoad() || OtherInstr.Description.mayStore())
+      continue;
     if (!ET.allowAsBackToBack(OtherInstr))
       continue;
     if (Instr->hasAliasingRegistersThrough(OtherInstr, ForbiddenRegisters))



More information about the llvm-commits mailing list