Skip to content

Commit d0d0e12

Browse files
authored
[AArch64] Fix a presumed typo in isFPImmLegal limit. NFC (#106716)
The worst possible case for a double literal goes like: ``` mov ... movk ..., lsl #16 movk ..., lsl #32 movk ..., lsl #48 fmov ... ``` The limit of 5 in the code gives the impression that `Insn` includes all instructions including the `fmov`, but that's not true. It only counts the integer moves. This led me astray on some other work in this area.
1 parent ef7b18a commit d0d0e12

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -11463,7 +11463,9 @@ bool AArch64TargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT,
1146311463
// movw+movk is fused). So we limit up to 2 instrdduction at most.
1146411464
SmallVector<AArch64_IMM::ImmInsnModel, 4> Insn;
1146511465
AArch64_IMM::expandMOVImm(ImmInt.getZExtValue(), VT.getSizeInBits(), Insn);
11466-
unsigned Limit = (OptForSize ? 1 : (Subtarget->hasFuseLiterals() ? 5 : 2));
11466+
assert(Insn.size() <= 4 &&
11467+
"Should be able to build any value with at most 4 moves");
11468+
unsigned Limit = (OptForSize ? 1 : (Subtarget->hasFuseLiterals() ? 4 : 2));
1146711469
IsLegal = Insn.size() <= Limit;
1146811470
}
1146911471

0 commit comments

Comments
 (0)