[llvm] AMDGPU: Fix -Wextra (PR #138539)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon May 5 08:16:55 PDT 2025


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/138539

Another stupid gcc warning. Ideally we would directly use the enum type,
but subregister indexes are emitted as an anonymous enum.

Fixes #125548

>From 7a4290f1358923928902ccfb8d41a22cb1e0fec3 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Mon, 5 May 2025 17:15:12 +0200
Subject: [PATCH] AMDGPU: Fix -Wextra

Another stupid gcc warning. Ideally we would directly use the enum type,
but subregister indexes are emitted as an anonymous enum.

Fixes #125548
---
 llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
index 9c9b3d5d4f97f..ca7b737f4437c 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -2521,8 +2521,9 @@ bool AMDGPUInstructionSelector::selectG_TRUNC(MachineInstr &I) const {
     return false;
 
   if (SrcSize > 32) {
-    unsigned SubRegIdx =
-        DstSize < 32 ? AMDGPU::sub0 : TRI.getSubRegFromChannel(0, DstSize / 32);
+    unsigned SubRegIdx = DstSize < 32
+                             ? static_cast<unsigned>(AMDGPU::sub0)
+                             : TRI.getSubRegFromChannel(0, DstSize / 32);
     if (SubRegIdx == AMDGPU::NoSubRegister)
       return false;
 



More information about the llvm-commits mailing list