[llvm] [AMDGPU] Insert MFMA anti-hints in GCNPreRAOptimizations (PR #218075)
Syadus Sefat via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 4 19:52:35 PDT 2026
================
@@ -0,0 +1,510 @@
+//===-- GCNPreRAAntiHints.cpp - MFMA register anti-hints ------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file
+/// Insert register allocation anti-hints.
+///
+//===----------------------------------------------------------------------===//
+
+#include "GCNPreRAAntiHints.h"
+#include "GCNSubtarget.h"
+#include "SIInstrInfo.h"
+#include "SIRegisterInfo.h"
+#include "llvm/CodeGen/LiveIntervals.h"
+#include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/CodeGen/SlotIndexes.h"
+#include "llvm/CodeGen/TargetSchedule.h"
+
+using namespace llvm;
+using namespace llvm::AMDGPU;
+
+#define DEBUG_TYPE "amdgpu-anti-hints"
+
+namespace HC = llvm::AMDGPU::HazardClass;
+
+static cl::opt<std::string> AntiHintRuleSelection(
+ "amdgpu-anti-hints-rules", cl::Hidden,
+ cl::desc("Comma-separated anti-hints rules (waw, war), or all or none."),
+ cl::init("all"));
+
+namespace {
+
+// Classify the MI into a HazardClassMask.
+HazardClassMask getInstHazardClass(const MachineInstr &MI,
+ const HazardContext &Ctx) {
----------------
mssefat wrote:
I agree. The current hazard resolution data stays in `GCNHazardRecognizer.cpp` and my `mfmaWaitStates` (and `wmmaCoexecWindow` in the next PR) reproduces them. It would probably make sense to move that into something like `AMDGPUHazardWaitStates.h` and share it across the passes. This seems to be better handled as a separate NFC change than as part of this PR.
@qcolombet If the rest looks fine to you would it be okay if I land this?
https://github.com/llvm/llvm-project/pull/218075
More information about the llvm-commits
mailing list