[llvm] [GlobalISel] Take the result size into account when const folding icmp (PR #134365)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 04:32:33 PDT 2025


================
@@ -1027,39 +1027,47 @@ llvm::ConstantFoldCountZeros(Register Src, const MachineRegisterInfo &MRI,
 
 std::optional<SmallVector<APInt>>
 llvm::ConstantFoldICmp(unsigned Pred, const Register Op1, const Register Op2,
+                       unsigned DstSizeInBits, unsigned ExtOp,
                        const MachineRegisterInfo &MRI) {
+  assert(ExtOp == TargetOpcode::G_SEXT || ExtOp == TargetOpcode::G_ZEXT ||
+         ExtOp == TargetOpcode::G_ANYEXT);
+
   LLT Ty = MRI.getType(Op1);
   if (Ty != MRI.getType(Op2))
     return std::nullopt;
----------------
arsenm wrote:

This should be unnecessary error checking 

https://github.com/llvm/llvm-project/pull/134365


More information about the llvm-commits mailing list