[llvm] [AArch64] Fix build-bot assertion error in AArch64 (PR #154124)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 18 07:36:11 PDT 2025


https://github.com/AZero13 updated https://github.com/llvm/llvm-project/pull/154124

>From 3e8eb22626d8d249b9110ab12c429189135e5919 Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Mon, 18 Aug 2025 10:32:11 -0400
Subject: [PATCH] Fix assertion error.

---
 llvm/lib/Target/AArch64/AArch64ISelLowering.cpp     | 13 +++++++------
 .../AArch64/GISel/AArch64PostLegalizerLowering.cpp  |  6 ++++--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index c27bf82157393..63a85faf344c4 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -4035,12 +4035,13 @@ static SDValue getAArch64Cmp(SDValue LHS, SDValue RHS, ISD::CondCode CC,
         break;
       case ISD::SETULE:
       case ISD::SETUGT: {
-        assert(!C.isAllOnes() && "C should not be -1 here");
-        APInt CPlusOne = C + 1;
-        if (isLegalCmpImmed(CPlusOne) ||
-            (NumImmForC > numberOfInstrToLoadImm(CPlusOne))) {
-          CC = (CC == ISD::SETULE) ? ISD::SETULT : ISD::SETUGE;
-          RHS = DAG.getConstant(CPlusOne, DL, VT);
+        if (!C.isAllOnes()) {
+          APInt CPlusOne = C + 1;
+          if (isLegalCmpImmed(CPlusOne) ||
+              (NumImmForC > numberOfInstrToLoadImm(CPlusOne))) {
+            CC = (CC == ISD::SETULE) ? ISD::SETULT : ISD::SETUGE;
+            RHS = DAG.getConstant(CPlusOne, DL, VT);
+          }
         }
         break;
       }
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp b/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp
index 2abe0dd0bbdc2..6025f1c9f5f4e 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp
@@ -639,8 +639,10 @@ tryAdjustICmpImmAndPred(Register RHS, CmpInst::Predicate P,
     // x ule c => x ult c + 1
     // x ugt c => s uge c + 1
     //
-    assert(C != (Size == 32 ? UINT32_MAX : UINT64_MAX) &&
-           "C should not be -1 here!");
+    // When c is not the largest possible unsigned integer.
+    if ((Size == 32 && static_cast<uint32_t>(C) == UINT32_MAX) ||
+        (Size == 64 && C == UINT64_MAX))
+      return std::nullopt;
     P = (P == CmpInst::ICMP_ULE) ? CmpInst::ICMP_ULT : CmpInst::ICMP_UGE;
     C += 1;
     break;



More information about the llvm-commits mailing list