[llvm] [AArch64] Return early rather than asserting when Size of value passed to targetShrinkDemandedConstant is not 32 or 64 (PR #123084)

Will Froom via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 09:07:17 PST 2025


https://github.com/WillFroom updated https://github.com/llvm/llvm-project/pull/123084

>From bfdd622ce2f40a782405f8e218661572edd247ff Mon Sep 17 00:00:00 2001
From: Will Froom <willfroom at google.com>
Date: Wed, 15 Jan 2025 16:32:31 +0000
Subject: [PATCH] [AArch64] Return early rather than asserting when Size of
 value passed to targetShrinkDemandedConstant is not 32 or 64

---
 llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index d4a114c275fb76..e0fdded1a2da33 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -2373,8 +2373,9 @@ bool AArch64TargetLowering::targetShrinkDemandedConstant(
     return false;
 
   unsigned Size = VT.getSizeInBits();
-  assert((Size == 32 || Size == 64) &&
-         "i32 or i64 is expected after legalization.");
+
+  if ((Size != 32) || (Size != 64))
+    return false;
 
   // Exit early if we demand all bits.
   if (DemandedBits.popcount() == Size)



More information about the llvm-commits mailing list