[llvm] [GlobalISel] Fix type mismatch in LegalizerHelper ternary (PR #180865)

Eric Christopher via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 13 11:09:03 PST 2026


https://github.com/echristo updated https://github.com/llvm/llvm-project/pull/180865

>From 19a498d222e0e2091b94fb1c144189dac3d23f3c Mon Sep 17 00:00:00 2001
From: Eric Christopher <echristo at gmail.com>
Date: Fri, 13 Feb 2026 09:27:09 -0800
Subject: [PATCH] Fix type mismatch in LegalizerHelper ternary

GCC requires explicit cast for enum-to-unsigned conversion in ternary
expressions when -Werror=extra is enabled.
---
 llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index e6eec3194b716..c5a5bf01384a0 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -6326,8 +6326,9 @@ Register LegalizerHelper::buildVariableShiftPart(unsigned Opcode,
   // For G_ASHR, individual parts don't have their own sign bit, only the
   // complete value does. So we use LSHR for the main operand shift in ASHR
   // context.
-  unsigned MainOpcode =
-      (Opcode == TargetOpcode::G_ASHR) ? TargetOpcode::G_LSHR : Opcode;
+  unsigned MainOpcode = (Opcode == TargetOpcode::G_ASHR)
+                            ? static_cast<unsigned>(TargetOpcode::G_LSHR)
+                            : Opcode;
 
   // Perform the primary shift on the main operand
   Register MainShifted =



More information about the llvm-commits mailing list