[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 08:52:32 PST 2025


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

See https://github.com/llvm/llvm-project/issues/123029 for details.

>From ab13871cc237ed34ecc30beaf2ce3b682a79808a 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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index d4a114c275fb76..32abcfe7a8f452 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -2373,8 +2373,11 @@ 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