[llvm] Make AMDGPUCombinerHelper methods const (PR #121740)
Paul Bowen-Huggett via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 6 01:08:18 PST 2025
https://github.com/paulhuggett created https://github.com/llvm/llvm-project/pull/121740
This is a follow-up to a previous PR (#119529) which eliminated several "TODO: make CombinerHelper methods const" remarks. As promised in that earlier change, this change completes the set by also making the methods of AMDGPUCombinerHelper const so that the Helper member of AMDGPUPreLegalizerCombinerImpl can be const rather than explicitly mutable.
>From fccef1450b8a3aebf0d73c47d24190b8abb43355 Mon Sep 17 00:00:00 2001
From: Paul Bowen-Huggett <paulhuggett at mac.com>
Date: Mon, 6 Jan 2025 09:50:46 +0100
Subject: [PATCH] Make AMDGPUCombinerHelper methods const
This is a follow-up to a previous commit (ee7ca0d) which eliminated
several "TODO: make CombinerHelper methods const" remarks. As promised
in that ealier commit, this change completes the set by also making
the methods of AMDGPUCombinerHelper const so that the Helper member of
AMDGPUPreLegalizerCombinerImpl can be const rather than explicitly
mutable.
---
llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.cpp | 8 ++++----
llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.h | 8 ++++----
llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp | 3 +--
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.cpp b/llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.cpp
index e5a376ab7357c1..6fa81170048999 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.cpp
@@ -190,7 +190,7 @@ static unsigned inverseMinMax(unsigned Opc) {
}
bool AMDGPUCombinerHelper::matchFoldableFneg(MachineInstr &MI,
- MachineInstr *&MatchInfo) {
+ MachineInstr *&MatchInfo) const {
Register Src = MI.getOperand(1).getReg();
MatchInfo = MRI.getVRegDef(Src);
@@ -259,7 +259,7 @@ bool AMDGPUCombinerHelper::matchFoldableFneg(MachineInstr &MI,
}
void AMDGPUCombinerHelper::applyFoldableFneg(MachineInstr &MI,
- MachineInstr *&MatchInfo) {
+ MachineInstr *&MatchInfo) const {
// Transform:
// %A = inst %Op1, ...
// %B = fneg %A
@@ -418,7 +418,7 @@ static bool isFPExtFromF16OrConst(const MachineRegisterInfo &MRI,
bool AMDGPUCombinerHelper::matchExpandPromotedF16FMed3(MachineInstr &MI,
Register Src0,
Register Src1,
- Register Src2) {
+ Register Src2) const {
assert(MI.getOpcode() == TargetOpcode::G_FPTRUNC);
Register SrcReg = MI.getOperand(1).getReg();
if (!MRI.hasOneNonDBGUse(SrcReg) || MRI.getType(SrcReg) != LLT::scalar(32))
@@ -431,7 +431,7 @@ bool AMDGPUCombinerHelper::matchExpandPromotedF16FMed3(MachineInstr &MI,
void AMDGPUCombinerHelper::applyExpandPromotedF16FMed3(MachineInstr &MI,
Register Src0,
Register Src1,
- Register Src2) {
+ Register Src2) const {
// We expect fptrunc (fpext x) to fold out, and to constant fold any constant
// sources.
Src0 = Builder.buildFPTrunc(LLT::scalar(16), Src0).getReg(0);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.h b/llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.h
index 6510abe9d23218..30601126e833bf 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCombinerHelper.h
@@ -23,13 +23,13 @@ class AMDGPUCombinerHelper : public CombinerHelper {
public:
using CombinerHelper::CombinerHelper;
- bool matchFoldableFneg(MachineInstr &MI, MachineInstr *&MatchInfo);
- void applyFoldableFneg(MachineInstr &MI, MachineInstr *&MatchInfo);
+ bool matchFoldableFneg(MachineInstr &MI, MachineInstr *&MatchInfo) const;
+ void applyFoldableFneg(MachineInstr &MI, MachineInstr *&MatchInfo) const;
bool matchExpandPromotedF16FMed3(MachineInstr &MI, Register Src0,
- Register Src1, Register Src2);
+ Register Src1, Register Src2) const;
void applyExpandPromotedF16FMed3(MachineInstr &MI, Register Src0,
- Register Src1, Register Src2);
+ Register Src1, Register Src2) const;
};
} // namespace llvm
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp
index ff8189ce31f7f7..ac431ccc30903e 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp
@@ -45,8 +45,7 @@ class AMDGPUPreLegalizerCombinerImpl : public Combiner {
protected:
const AMDGPUPreLegalizerCombinerImplRuleConfig &RuleConfig;
const GCNSubtarget &STI;
- // TODO: Make CombinerHelper methods const.
- mutable AMDGPUCombinerHelper Helper;
+ const AMDGPUCombinerHelper Helper;
public:
AMDGPUPreLegalizerCombinerImpl(
More information about the llvm-commits
mailing list