[llvm-commits] [llvm] r45768 - in /llvm/trunk/lib/Target/X86: README.txt X86InstrInfo.cpp
Chris Lattner
sabre at nondot.org
Tue Jan 8 16:37:20 PST 2008
Author: lattner
Date: Tue Jan 8 18:37:18 2008
New Revision: 45768
URL: http://llvm.org/viewvc/llvm-project?rev=45768&view=rev
Log:
add a testcase
Modified:
llvm/trunk/lib/Target/X86/README.txt
llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
Modified: llvm/trunk/lib/Target/X86/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=45768&r1=45767&r2=45768&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/README.txt (original)
+++ llvm/trunk/lib/Target/X86/README.txt Tue Jan 8 18:37:18 2008
@@ -1601,13 +1601,13 @@
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 @@
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;
+}
//===---------------------------------------------------------------------===//
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=45768&r1=45767&r2=45768&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Tue Jan 8 18:37:18 2008
@@ -1740,8 +1740,7 @@
// 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,
- SmallVectorImpl<unsigned> &Ops,
- MachineInstr *LoadMI) const {
+ SmallVectorImpl<unsigned> &Ops,
+ MachineInstr *LoadMI) const {
// Check switch flag
if (NoFusing) return NULL;
@@ -1802,7 +1801,7 @@
bool X86InstrInfo::canFoldMemoryOperand(MachineInstr *MI,
- SmallVectorImpl<unsigned> &Ops) const {
+ SmallVectorImpl<unsigned> &Ops) const {
// Check switch flag
if (NoFusing) return 0;
More information about the llvm-commits
mailing list