[X86] Fix AvoidStoreForwardingBlocks pass for negative displacements
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 10 Dec 2018 10:16:50 +0000 (10:16 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 10 Dec 2018 10:16:50 +0000 (10:16 +0000)
commite79477895e1af4425aecaded2881e3b3c878faf5
tree6503d83459b9f20bd928808f12220b80137cc2ae
parent1f958ed2693e889b6a02c7381578d2d202a1a409
[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

llvm-svn: 348750
llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp
llvm/test/CodeGen/X86/pr39926.ll