[llvm] [GlobalISel] Fix type mismatch in LegalizerHelper ternary (PR #180865)
Eric Christopher via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 10 17:48:51 PST 2026
https://github.com/echristo updated https://github.com/llvm/llvm-project/pull/180865
>From 08ded8d0f99e40f287502681579388e38c43bc26 Mon Sep 17 00:00:00 2001
From: Eric Christopher <echristo at gmail.com>
Date: Fri, 6 Feb 2026 01:50:06 -0800
Subject: [PATCH] ### Summary
Fix type mismatch in ternary that causes GCC `-Werror=extra` to fail.
#### Details
GCC's `-Werror=extra` enforces stricter type consistency in ternary expressions, in this case const-qualified unsigned variable with enum literal.
### Tested
- Built with ToT clang and GCC 13.3.0 on Linux x86_64.
- All existing tests pass
---
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..b22c9f0e41b85 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)
+ ? (unsigned)TargetOpcode::G_LSHR
+ : Opcode;
// Perform the primary shift on the main operand
Register MainShifted =
More information about the llvm-commits
mailing list