Skip to content

Commit 7c90be2

Browse files
[SVE] Fix incorrect offset calculation when rewriting an instruction's frame index. (#70315)
When partially packing an offset into an SVE load/store instruction we are incorrectly calculating the remainder.
1 parent b1b9cd4 commit 7c90be2

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5657,7 +5657,7 @@ int llvm::isAArch64FrameOffsetLegal(const MachineInstr &MI,
56575657
Offset = Remainder;
56585658
else {
56595659
NewOffset = NewOffset < 0 ? MinOff : MaxOff;
5660-
Offset = Offset - NewOffset * Scale + Remainder;
5660+
Offset = Offset - NewOffset * Scale;
56615661
}
56625662

56635663
if (EmittableOffset)

llvm/test/CodeGen/AArch64/framelayout-sve.mir

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
define aarch64_sve_vector_pcs void @save_restore_sve_realign() uwtable { entry: unreachable }
4242
define aarch64_sve_vector_pcs void @frame_layout() uwtable { entry: unreachable }
4343
define void @fp_relative_index_with_float_save() uwtable { entry: unreachable }
44+
define void @fp_relative_that_is_not_a_multiple_of_VLx16() uwtable { entry: unreachable }
4445

4546
...
4647
# +----------+
@@ -1287,3 +1288,24 @@ body: |
12871288
12881289
RET_ReallyLR
12891290
---
1291+
...
1292+
# CHECK-LABEL: name: fp_relative_that_is_not_a_multiple_of_VLx16
1293+
# CHECK: - { id: 0, name: '', type: default, offset: -156, size: 156, alignment: 1,
1294+
# CHECK-NEXT: stack-id: scalable-vector
1295+
# CHECK: - { id: 1, name: '', type: variable-sized, offset: -32, alignment: 1,
1296+
# CHECK-NEXT: stack-id: default
1297+
1298+
# CHECK: $x8 = ADDPL_XXI $fp, -14
1299+
# CHECK-NEXT: $z0 = LD1W_IMM killed renamable $p0, killed $x8, -8
1300+
1301+
name: fp_relative_that_is_not_a_multiple_of_VLx16
1302+
stack:
1303+
- { id: 0, stack-id: scalable-vector, size: 156, alignment: 1 }
1304+
- { id: 1, stack-id: default, type: variable-sized, alignment: 1 }
1305+
body: |
1306+
bb.0.entry:
1307+
liveins: $p0
1308+
1309+
renamable $z0 = LD1W_IMM killed renamable $p0, %stack.0, 0
1310+
RET_ReallyLR
1311+
---

0 commit comments

Comments
 (0)