[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp X86InstrInfo.td

Evan Cheng evan.cheng at apple.com
Mon May 29 23:59:48 PDT 2006



Changes in directory llvm/lib/Target/X86:

X86ISelDAGToDAG.cpp updated: 1.69 -> 1.70
X86InstrInfo.td updated: 1.271 -> 1.272
---
Log message:

A addressing mode folding enhancement:
Fold c2 in (x << c1) | c2 where (c2 < c1)
e.g.
int test(int x) {
  return (x << 3) + 7;
}

This can be codegen'd as:
leal 7(,%eax,8), %eax


---
Diffs of the changes:  (+25 -1)

 X86ISelDAGToDAG.cpp |   24 ++++++++++++++++++++++++
 X86InstrInfo.td     |    2 +-
 2 files changed, 25 insertions(+), 1 deletion(-)


Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
diff -u llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.69 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.70
--- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.69	Wed May 24 19:24:27 2006
+++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp	Tue May 30 01:59:36 2006
@@ -392,6 +392,30 @@
     }
     break;
   }
+
+  case ISD::OR: {
+    if (!Available) {
+      X86ISelAddressMode Backup = AM;
+      // Look for (x << c1) | c2 where (c2 < c1)
+      ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N.Val->getOperand(0));
+      if (CN && !MatchAddress(N.Val->getOperand(1), AM, false)) {
+        if (AM.GV == NULL && AM.Disp == 0 && CN->getValue() < AM.Scale) {
+          AM.Disp = CN->getValue();
+          return false;
+        }
+      }
+      AM = Backup;
+      CN = dyn_cast<ConstantSDNode>(N.Val->getOperand(1));
+      if (CN && !MatchAddress(N.Val->getOperand(0), AM, false)) {
+        if (AM.GV == NULL && AM.Disp == 0 && CN->getValue() < AM.Scale) {
+          AM.Disp = CN->getValue();
+          return false;
+        }
+      }
+      AM = Backup;
+    }
+    break;
+  }
   }
 
   // Is the base register already occupied?


Index: llvm/lib/Target/X86/X86InstrInfo.td
diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.271 llvm/lib/Target/X86/X86InstrInfo.td:1.272
--- llvm/lib/Target/X86/X86InstrInfo.td:1.271	Fri May 19 20:40:16 2006
+++ llvm/lib/Target/X86/X86InstrInfo.td	Tue May 30 01:59:36 2006
@@ -133,7 +133,7 @@
 // Define X86 specific addressing mode.
 def addr    : ComplexPattern<iPTR, 4, "SelectAddr", []>;
 def leaaddr : ComplexPattern<iPTR, 4, "SelectLEAAddr",
-                             [add, mul, shl, frameindex]>;
+                             [add, mul, shl, or, frameindex]>;
 
 //===----------------------------------------------------------------------===//
 // X86 Instruction Format Definitions.






More information about the llvm-commits mailing list