From c032b2beb08471cb4599f263c82ea4b4f5a42ad8 Mon Sep 17 00:00:00 2001 From: Geoff Berry Date: Wed, 27 Sep 2017 17:14:10 +0000 Subject: [PATCH] [AArch64][Falkor] Ignore SP based loads in HW prefetch fixups. Reviewers: mcrosier Subscribers: aemerson, rengolin, javed.absar, kristof.beyls Differential Revision: https://reviews.llvm.org/D38301 llvm-svn: 314319 --- llvm/lib/Target/AArch64/AArch64FalkorHWPFFix.cpp | 7 ++++++- llvm/test/CodeGen/AArch64/falkor-hwpf-fix.mir | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/AArch64/AArch64FalkorHWPFFix.cpp b/llvm/lib/Target/AArch64/AArch64FalkorHWPFFix.cpp index 6df8df0..3acacf7 100644 --- a/llvm/lib/Target/AArch64/AArch64FalkorHWPFFix.cpp +++ b/llvm/lib/Target/AArch64/AArch64FalkorHWPFFix.cpp @@ -638,9 +638,14 @@ static Optional getLoadInfo(const MachineInstr &MI) { break; } + // Loads from the stack pointer don't get prefetched. + unsigned BaseReg = MI.getOperand(BaseRegIdx).getReg(); + if (BaseReg == AArch64::SP || BaseReg == AArch64::WSP) + return None; + LoadInfo LI; LI.DestReg = DestRegIdx == -1 ? 0 : MI.getOperand(DestRegIdx).getReg(); - LI.BaseReg = MI.getOperand(BaseRegIdx).getReg(); + LI.BaseReg = BaseReg; LI.BaseRegIdx = BaseRegIdx; LI.OffsetOpnd = OffsetIdx == -1 ? nullptr : &MI.getOperand(OffsetIdx); LI.IsPrePost = IsPrePost; diff --git a/llvm/test/CodeGen/AArch64/falkor-hwpf-fix.mir b/llvm/test/CodeGen/AArch64/falkor-hwpf-fix.mir index 70da36c..38622ae 100644 --- a/llvm/test/CodeGen/AArch64/falkor-hwpf-fix.mir +++ b/llvm/test/CodeGen/AArch64/falkor-hwpf-fix.mir @@ -330,3 +330,26 @@ body: | bb.1: RET_ReallyLR ... +--- +# Check that we treat sp based loads as non-prefetching. + +# CHECK-LABEL: name: hwpf_spbase +# CHECK-NOT: ORRXrs %xzr +# CHECK: LDRWui %x15 +# CHECK: LDRWui %sp +name: hwpf_spbase +tracksRegLiveness: true +body: | + bb.0: + liveins: %w0, %x15 + + %w1 = LDRWui %x15, 0 :: ("aarch64-strided-access" load 4) + %w17 = LDRWui %sp, 0 + + %w0 = SUBWri %w0, 1, 0 + %wzr = SUBSWri %w0, 0, 0, implicit-def %nzcv + Bcc 9, %bb.0, implicit %nzcv + + bb.1: + RET_ReallyLR +... -- 2.7.4