Skip to content

Commit ed849dc

Browse files
committed
[ARM] Fix FP16 stack loads/stores for Thumb2 with frame pointer
The new addressing mode added for the v8.2A FP16 instructions uses bit 8 of the immediate to encode the sign of the offset, like the other FP loads/stores, so need to be treated the same way. Differential revision: https://reviews.llvm.org/D58816 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355201 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c064077 commit ed849dc

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/Target/ARM/Thumb2InstrInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ bool llvm::rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx,
638638
// Replace the FrameIndex with fp/sp
639639
MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg, false);
640640
if (isSub) {
641-
if (AddrMode == ARMII::AddrMode5)
641+
if (AddrMode == ARMII::AddrMode5 || AddrMode == ARMII::AddrMode5FP16)
642642
// FIXME: Not consistent.
643643
ImmedOffset |= 1 << NumBits;
644644
else
@@ -652,7 +652,7 @@ bool llvm::rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx,
652652
// Otherwise, offset doesn't fit. Pull in what we can to simplify
653653
ImmedOffset = ImmedOffset & Mask;
654654
if (isSub) {
655-
if (AddrMode == ARMII::AddrMode5)
655+
if (AddrMode == ARMII::AddrMode5 || AddrMode == ARMII::AddrMode5FP16)
656656
// FIXME: Not consistent.
657657
ImmedOffset |= 1 << NumBits;
658658
else {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: llc < %s -mtriple armv8a--none-eabi -mattr=+fullfp16 | FileCheck %s
2+
; RUN: llc < %s -mtriple armv8a--none-eabi -mattr=+fullfp16,+thumb-mode | FileCheck %s
3+
4+
; Check that frame lowering for the fp16 instructions works correctly with
5+
; negative offsets (which happens when using the frame pointer).
6+
7+
define void @foo(i32 %count) {
8+
entry:
9+
%half_alloca = alloca half, align 2
10+
; CHECK: vstr.16 {{s[0-9]+}}, [{{r[0-9]+}}, #-10]
11+
store half 0.0, half* %half_alloca
12+
call void @bar(half* %half_alloca)
13+
14+
; A variable-sized alloca to force the above store to use the frame pointer
15+
; instead of the stack pointer, and so need a negative offset.
16+
%var_alloca = alloca i32, i32 %count
17+
call void @baz(i32* %var_alloca)
18+
ret void
19+
}
20+
21+
declare void @bar(half*)
22+
declare void @baz(i32*)

0 commit comments

Comments
 (0)