[llvm] 74be8ed - [GlobalISel] Fix type mismatch in LegalizerHelper ternary (#180865)

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 13 19:36:06 PST 2026


Author: Eric Christopher
Date: 2026-02-13T19:36:02-08:00
New Revision: 74be8edf939427e100b505027298d7d2552f08cd

URL: https://github.com/llvm/llvm-project/commit/74be8edf939427e100b505027298d7d2552f08cd
DIFF: https://github.com/llvm/llvm-project/commit/74be8edf939427e100b505027298d7d2552f08cd.diff

LOG: [GlobalISel] Fix type mismatch in LegalizerHelper ternary (#180865)

### Summary

Fix type mismatch in ternary expression that causes GCC `-Werror=extra`
to fail.

### Details

GCC's `-Werror=extra` enforces stricter type consistency in ternary
expressions, in this case unsigned and an enum literal.

### Tested

- Built with ToT clang and GCC 13.3.0 on Linux x86_64 (not really
because there are other warnings, but this one is gone).
- All existing tests pass

Added: 
    

Modified: 
    llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index f6c57ed5537a3..41b79ccb4e4d1 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