diff options
author | Chris Lattner <sabre@nondot.org> | 2008-01-09 00:37:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-01-09 00:37:18 +0000 |
commit | 269f0595d628eb5d2cf12d11bcda6bd69a73f509 (patch) | |
tree | edf510e0c39f060473c0c8d670f317120021d171 | |
parent | f61b63ec5b36857f34d3ec93afcd53557369373c (diff) |
add a testcase
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45768 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/README.txt | 21 | ||||
-rw-r--r-- | lib/Target/X86/X86InstrInfo.cpp | 9 |
2 files changed, 20 insertions, 10 deletions
diff --git a/lib/Target/X86/README.txt b/lib/Target/X86/README.txt index be37acfa8a..b239dc3edd 100644 --- a/lib/Target/X86/README.txt +++ b/lib/Target/X86/README.txt @@ -1601,13 +1601,13 @@ This would result in smaller code and more efficient microops. In SSE mode, we turn abs and neg into a load from the constant pool plus a xor or and instruction, for example: - xorpd LCPI2_0-"L2$pb"(%esi), %xmm2 + xorpd LCPI1_0, %xmm2 However, if xmm2 gets spilled, we end up with really ugly code like this: - %xmm2 = reload [mem] - xorpd LCPI2_0-"L2$pb"(%esi), %xmm2 - store %xmm2 -> [mem] + movsd (%esp), %xmm0 + xorpd LCPI1_0, %xmm0 + movsd %xmm0, (%esp) Since we 'know' that this is a 'neg', we can actually "fold" the spill into the neg/abs instruction, turning it into an *integer* operation, like this: @@ -1615,6 +1615,17 @@ the neg/abs instruction, turning it into an *integer* operation, like this: xorl 2147483648, [mem+4] ## 2147483648 = (1 << 31) you could also use xorb, but xorl is less likely to lead to a partial register -stall. +stall. Here is a contrived testcase: + +double a, b, c; +void test(double *P) { + double X = *P; + a = X; + bar(); + X = -X; + b = X; + bar(); + c = X; +} //===---------------------------------------------------------------------===// diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index a24140cb0d..c731328860 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -1740,8 +1740,7 @@ X86InstrInfo::foldMemoryOperand(MachineInstr *MI, unsigned i, // No fusion if (PrintFailedFusing) - cerr << "We failed to fuse (" - << ((i == 1) ? "r" : "s") << "): " << *MI; + cerr << "We failed to fuse operand " << i << *MI; return NULL; } @@ -1773,8 +1772,8 @@ MachineInstr* X86InstrInfo::foldMemoryOperand(MachineInstr *MI, } MachineInstr* X86InstrInfo::foldMemoryOperand(MachineInstr *MI, - SmallVectorImpl<unsigned> &Ops, - MachineInstr *LoadMI) const { + SmallVectorImpl<unsigned> &Ops, + MachineInstr *LoadMI) const { // Check switch flag if (NoFusing) return NULL; @@ -1802,7 +1801,7 @@ MachineInstr* X86InstrInfo::foldMemoryOperand(MachineInstr *MI, bool X86InstrInfo::canFoldMemoryOperand(MachineInstr *MI, - SmallVectorImpl<unsigned> &Ops) const { + SmallVectorImpl<unsigned> &Ops) const { // Check switch flag if (NoFusing) return 0; |