Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 47d569d

Browse files
committed
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348750 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 9af7ae8 commit 47d569d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ void X86AvoidSFBPass::breakBlockedCopies(
586586
StDisp2 += OverlapDelta;
587587
Size2 -= OverlapDelta;
588588
}
589-
Size1 = std::abs(std::abs(LdDisp2) - std::abs(LdDisp1));
589+
Size1 = LdDisp2 - LdDisp1;
590590

591591
// Build a copy for the point until the current blocking store's
592592
// displacement.

test/CodeGen/X86/pr39926.ll

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ define i8 @test_offset(i8* %base) {
88
; CHECK-NEXT: movb $0, 7(%rdi)
99
; CHECK-NEXT: movw $0, 5(%rdi)
1010
; CHECK-NEXT: movl $0, 1(%rdi)
11-
; CHECK-NEXT: movzwl -4(%rdi), %eax
12-
; CHECK-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
13-
; CHECK-NEXT: movb -2(%rdi), %al
11+
; CHECK-NEXT: movl -4(%rdi), %eax
12+
; CHECK-NEXT: movl %eax, -{{[0-9]+}}(%rsp)
13+
; CHECK-NEXT: movb (%rdi), %al
1414
; CHECK-NEXT: movb %al, -{{[0-9]+}}(%rsp)
1515
; CHECK-NEXT: movl 1(%rdi), %eax
1616
; CHECK-NEXT: movl %eax, -{{[0-9]+}}(%rsp)

0 commit comments

Comments
 (0)