[llvm] 549413f - [AArch64][GlobalISel] Protect against folding loads across basic blocks.
David Green via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 16 11:52:48 PST 2024
Author: David Green
Date: 2024-11-16T19:52:44Z
New Revision: 549413fa4034898250c506098c3602e0b07680a2
URL: https://github.com/llvm/llvm-project/commit/549413fa4034898250c506098c3602e0b07680a2
DIFF: https://github.com/llvm/llvm-project/commit/549413fa4034898250c506098c3602e0b07680a2.diff
LOG: [AArch64][GlobalISel] Protect against folding loads across basic blocks.
isObviouslySafeToFold can look between a load and an instruction it can be
folded into, to check that no other memory operations prevents the fold. It
doesn't handle multiple basic blocks which we needs to guard against.
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/GIMatchTableExecutor.cpp
llvm/test/CodeGen/AArch64/neon-vector-splat.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/GIMatchTableExecutor.cpp b/llvm/lib/CodeGen/GlobalISel/GIMatchTableExecutor.cpp
index 1a887ab5794b06..1edfc093105545 100644
--- a/llvm/lib/CodeGen/GlobalISel/GIMatchTableExecutor.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/GIMatchTableExecutor.cpp
@@ -98,5 +98,5 @@ bool GIMatchTableExecutor::isObviouslySafeToFold(MachineInstr &MI,
return true;
}
- return true;
+ return !MI.mayLoad();
}
diff --git a/llvm/test/CodeGen/AArch64/neon-vector-splat.ll b/llvm/test/CodeGen/AArch64/neon-vector-splat.ll
index 1a253aa2761040..489eaf179a1bd2 100644
--- a/llvm/test/CodeGen/AArch64/neon-vector-splat.ll
+++ b/llvm/test/CodeGen/AArch64/neon-vector-splat.ll
@@ -126,24 +126,15 @@ define <2 x ptr> @shuffle8(ptr %P) {
}
define <4 x i32> @multiblock_aliasing(ptr %P, i1 %c) {
-; CHECK-SD-LABEL: multiblock_aliasing:
-; CHECK-SD: // %bb.0: // %entry
-; CHECK-SD-NEXT: ldr q0, [x0]
-; CHECK-SD-NEXT: tbz w1, #0, .LBB9_2
-; CHECK-SD-NEXT: // %bb.1: // %then
-; CHECK-SD-NEXT: stp xzr, xzr, [x0]
-; CHECK-SD-NEXT: .LBB9_2: // %else
-; CHECK-SD-NEXT: dup v0.4s, v0.s[0]
-; CHECK-SD-NEXT: ret
-;
-; CHECK-GI-LABEL: multiblock_aliasing:
-; CHECK-GI: // %bb.0: // %entry
-; CHECK-GI-NEXT: tbz w1, #0, .LBB9_2
-; CHECK-GI-NEXT: // %bb.1: // %then
-; CHECK-GI-NEXT: stp xzr, xzr, [x0]
-; CHECK-GI-NEXT: .LBB9_2: // %else
-; CHECK-GI-NEXT: ld1r { v0.4s }, [x0]
-; CHECK-GI-NEXT: ret
+; CHECK-LABEL: multiblock_aliasing:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: ldr q0, [x0]
+; CHECK-NEXT: tbz w1, #0, .LBB9_2
+; CHECK-NEXT: // %bb.1: // %then
+; CHECK-NEXT: stp xzr, xzr, [x0]
+; CHECK-NEXT: .LBB9_2: // %else
+; CHECK-NEXT: dup v0.4s, v0.s[0]
+; CHECK-NEXT: ret
entry:
%lv2ptr = load <4 x i32>, ptr %P
br i1 %c, label %then, label %else
More information about the llvm-commits
mailing list