Skip to content

Commit 90b60f9

Browse files
committed
[AArch64] Fix crash for expandMOVImm
Fix #59892 Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D141258
1 parent 73eb5db commit 90b60f9

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9773,8 +9773,7 @@ bool AArch64TargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT,
97739773
// movw+movk+fmov vs. adrp+ldr (it's one instruction longer, but the
97749774
// movw+movk is fused). So we limit up to 2 instrdduction at most.
97759775
SmallVector<AArch64_IMM::ImmInsnModel, 4> Insn;
9776-
AArch64_IMM::expandMOVImm(ImmInt.getZExtValue(), VT.getSizeInBits(),
9777-
Insn);
9776+
AArch64_IMM::expandMOVImm(ImmInt.getZExtValue(), VT.getSizeInBits(), Insn);
97789777
unsigned Limit = (OptForSize ? 1 : (Subtarget->hasFuseLiterals() ? 5 : 2));
97799778
IsLegal = Insn.size() <= Limit;
97809779
}
@@ -14819,7 +14818,9 @@ bool AArch64TargetLowering::isMulAddWithConstProfitable(
1481914818
if (!isLegalAddImmediate(C1) || isLegalAddImmediate(C1C2.getSExtValue()))
1482014819
return true;
1482114820
SmallVector<AArch64_IMM::ImmInsnModel, 4> Insn;
14822-
AArch64_IMM::expandMOVImm(C1C2.getZExtValue(), VT.getSizeInBits(), Insn);
14821+
// Adapt to the width of a register.
14822+
unsigned BitSize = VT.getSizeInBits() <= 32 ? 32 : 64;
14823+
AArch64_IMM::expandMOVImm(C1C2.getZExtValue(), BitSize, Insn);
1482314824
if (Insn.size() > 1)
1482414825
return false;
1482514826

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel -verify-machineinstrs < %s | FileCheck %s --check-prefix=FISEL
3+
4+
define i53 @PR59892 () {
5+
; FISEL-LABEL: PR59892:
6+
; FISEL: // %bb.0:
7+
; FISEL-NEXT: mov x8, #47668
8+
; FISEL-NEXT: movk x8, #4645, lsl #16
9+
; FISEL-NEXT: movk x8, #58741, lsl #32
10+
; FISEL-NEXT: movk x8, #1, lsl #48
11+
; FISEL-NEXT: orr x9, x8, #0x2
12+
; FISEL-NEXT: mul x0, x9, x8
13+
; FISEL-NEXT: ret
14+
%a = mul nsw i53 533765955107380, 533765955107382
15+
ret i53 %a
16+
}

0 commit comments

Comments
 (0)