[llvm] r348750 - [X86] Fix AvoidStoreForwardingBlocks pass for negative displacements
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 10 02:16:51 PST 2018
Author: nikic
Date: Mon Dec 10 02:16:50 2018
New Revision: 348750
URL: http://llvm.org/viewvc/llvm-project?rev=348750&view=rev
Log:
[X86] Fix AvoidStoreForwardingBlocks pass for negative displacements
Fixes https://bugs.llvm.org/show_bug.cgi?id=39926.
The size of the first copy was computed as
std::abs(std::abs(LdDisp2) - std::abs(LdDisp1)), which results in
skipped bytes if the signs of LdDisp2 and LdDisp1 differ. As far as
I can see, this should just be LdDisp2 - LdDisp1. The case where
LdDisp1 > LdDisp2 is already handled in the code above, in which case
LdDisp2 is set to LdDisp1 and this subtraction will evaluate to
Size1 = 0, which is the correct value to skip an overlapping copy.
Differential Revision: https://reviews.llvm.org/D55485
Modified:
llvm/trunk/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp
llvm/trunk/test/CodeGen/X86/pr39926.ll
Modified: llvm/trunk/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp?rev=348750&r1=348749&r2=348750&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp Mon Dec 10 02:16:50 2018
@@ -586,7 +586,7 @@ void X86AvoidSFBPass::breakBlockedCopies
StDisp2 += OverlapDelta;
Size2 -= OverlapDelta;
}
- Size1 = std::abs(std::abs(LdDisp2) - std::abs(LdDisp1));
+ Size1 = LdDisp2 - LdDisp1;
// Build a copy for the point until the current blocking store's
// displacement.
Modified: llvm/trunk/test/CodeGen/X86/pr39926.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr39926.ll?rev=348750&r1=348749&r2=348750&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pr39926.ll (original)
+++ llvm/trunk/test/CodeGen/X86/pr39926.ll Mon Dec 10 02:16:50 2018
@@ -8,9 +8,9 @@ define i8 @test_offset(i8* %base) {
; CHECK-NEXT: movb $0, 7(%rdi)
; CHECK-NEXT: movw $0, 5(%rdi)
; CHECK-NEXT: movl $0, 1(%rdi)
-; CHECK-NEXT: movzwl -4(%rdi), %eax
-; CHECK-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
-; CHECK-NEXT: movb -2(%rdi), %al
+; CHECK-NEXT: movl -4(%rdi), %eax
+; CHECK-NEXT: movl %eax, -{{[0-9]+}}(%rsp)
+; CHECK-NEXT: movb (%rdi), %al
; CHECK-NEXT: movb %al, -{{[0-9]+}}(%rsp)
; CHECK-NEXT: movl 1(%rdi), %eax
; CHECK-NEXT: movl %eax, -{{[0-9]+}}(%rsp)
More information about the llvm-commits
mailing list