[PATCH] D77599: [AArch64] Don't expand memcmp in strict align mode.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 6 15:49:12 PDT 2020
efriedma created this revision.
efriedma added reviewers: courbet, aqjune.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: LLVM.
7aecf232 <https://reviews.llvm.org/rG7aecf2323c4ef007ed443d9a58703fe08815b805> fixed the bug where we would miscompile, but we still generate a crazy amount of code. Turn off the expansion until someone implements an appropriate heuristic.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77599
Files:
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
llvm/test/CodeGen/AArch64/bcmp-inline-small.ll
Index: llvm/test/CodeGen/AArch64/bcmp-inline-small.ll
===================================================================
--- llvm/test/CodeGen/AArch64/bcmp-inline-small.ll
+++ llvm/test/CodeGen/AArch64/bcmp-inline-small.ll
@@ -11,12 +11,12 @@
ret i1 %ret
; CHECK-LABEL: test_b2:
-; CHECK-NOT: bl bcmp
+; CHECKN-NOT: bl bcmp
; CHECKN: ldr x
; CHECKN-NEXT: ldr x
; CHECKN-NEXT: ldur x
; CHECKN-NEXT: ldur x
-; CHECKS-COUNT-30: ldrb w
+; CHECKS: bl bcmp
}
define i1 @test_b2_align8(i8* align 8 %s1, i8* align 8 %s2) {
@@ -26,19 +26,13 @@
ret i1 %ret
; CHECK-LABEL: test_b2_align8:
-; CHECK-NOT: bl bcmp
+; CHECKN-NOT: bl bcmp
; CHECKN: ldr x
; CHECKN-NEXT: ldr x
; CHECKN-NEXT: ldur x
; CHECKN-NEXT: ldur x
-; CHECKS: ldr x
-; CHECKS-NEXT: ldr x
-; CHECKS-NEXT: ldr w
-; CHECKS-NEXT: ldr w
-; CHECKS-NEXT: ldrh w
-; CHECKS-NEXT: ldrh w
-; CHECKS-NEXT: ldrb w
-; CHECKS-NEXT: ldrb w
+; TODO: Four loads should be within the limit, but the heuristic isn't implemented.
+; CHECKS: bl bcmp
}
define i1 @test_bs(i8* %s1, i8* %s2) optsize {
Index: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -629,7 +629,12 @@
AArch64TTIImpl::TTI::MemCmpExpansionOptions
AArch64TTIImpl::enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const {
TTI::MemCmpExpansionOptions Options;
- Options.AllowOverlappingLoads = !ST->requiresStrictAlign();
+ if (ST->requiresStrictAlign()) {
+ // TODO: Add cost modeling for strict align. Misaligned loads expand to
+ // a bunch of instructions when strict align is enabled.
+ return Options;
+ }
+ Options.AllowOverlappingLoads = true;
Options.MaxNumLoads = TLI->getMaxExpandSizeMemcmp(OptSize);
Options.NumLoadsPerBlock = Options.MaxNumLoads;
// TODO: Though vector loads usually perform well on AArch64, in some targets
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77599.255511.patch
Type: text/x-patch
Size: 2025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200406/c588a212/attachment.bin>
More information about the llvm-commits
mailing list