[llvm] [AMDGPU] Remove HasSampler variable. NFC. (PR #146682)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 2 05:47:41 PDT 2025


https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/146682

Putting the complex condition in a variable does not help readability.
It is simpler to use separate `if`s.


>From 61422810b0beb65a90194bf8fb8256967e479332 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Wed, 2 Jul 2025 13:43:40 +0100
Subject: [PATCH] [AMDGPU] Remove HasSampler variable. NFC.

Putting the complex condition in a variable does not help readability.
It is simpler to use separate `if`s.
---
 llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index 6414e81baae70..1db8d6665efee 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -203,12 +203,17 @@ VmemType getVmemType(const MachineInstr &Inst) {
   const AMDGPU::MIMGInfo *Info = AMDGPU::getMIMGInfo(Inst.getOpcode());
   const AMDGPU::MIMGBaseOpcodeInfo *BaseInfo =
       AMDGPU::getMIMGBaseOpcodeInfo(Info->BaseOpcode);
+
+  if (BaseInfo->BVH)
+    return VMEM_BVH;
+
   // We have to make an additional check for isVSAMPLE here since some
   // instructions don't have a sampler, but are still classified as sampler
   // instructions for the purposes of e.g. waitcnt.
-  bool HasSampler =
-      BaseInfo->Sampler || BaseInfo->MSAA || SIInstrInfo::isVSAMPLE(Inst);
-  return BaseInfo->BVH ? VMEM_BVH : HasSampler ? VMEM_SAMPLER : VMEM_NOSAMPLER;
+  if (BaseInfo->Sampler || BaseInfo->MSAA || SIInstrInfo::isVSAMPLE(Inst))
+    return VMEM_SAMPLER;
+
+  return VMEM_NOSAMPLER;
 }
 
 unsigned &getCounterRef(AMDGPU::Waitcnt &Wait, InstCounterType T) {



More information about the llvm-commits mailing list