Skip to content

Commit 8df0cc3

Browse files
committed
[AArch64] Return early rather than asserting when Size of value passed to targetShrinkDemandedConstant is not 32 or 64
1 parent d0a3642 commit 8df0cc3

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,8 +2373,9 @@ bool AArch64TargetLowering::targetShrinkDemandedConstant(
23732373
return false;
23742374

23752375
unsigned Size = VT.getSizeInBits();
2376-
assert((Size == 32 || Size == 64) &&
2377-
"i32 or i64 is expected after legalization.");
2376+
2377+
if (Size != 32 && Size != 64)
2378+
return false;
23782379

23792380
// Exit early if we demand all bits.
23802381
if (DemandedBits.popcount() == Size)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: llc -o - %s
2+
3+
; Simply check that the following does not crash (see https://github.com/llvm/llvm-project/issues/123029)
4+
5+
target triple = "aarch64-unknown-linux-gnu"
6+
7+
define noalias noundef ptr @fn(ptr nocapture readonly %in, ptr nocapture readonly %out) local_unnamed_addr {
8+
fn:
9+
%1 = load <4 x half>, ptr %in, align 16
10+
%2 = fcmp one <4 x half> %1, zeroinitializer
11+
%3 = uitofp <4 x i1> %2 to <4 x half>
12+
store <4 x half> %3, ptr %out, align 16
13+
14+
%23 = getelementptr inbounds nuw i8, ptr %in, i64 8
15+
%24 = load half, ptr %23, align 4
16+
%25 = fcmp one half %24, 0xH0000
17+
%26 = uitofp i1 %25 to half
18+
%27 = call half @llvm.copysign.f16(half %26, half %24)
19+
%30 = getelementptr inbounds nuw i8, ptr %out, i64 8
20+
store half %27, ptr %30, align 8
21+
ret ptr null
22+
}

0 commit comments

Comments
 (0)