OSDN Git Service

Don't match x << 1 to LEAL. It's better to emit x + x.
authorEvan Cheng <evan.cheng@apple.com>
Tue, 28 Feb 2006 21:13:57 +0000 (21:13 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 28 Feb 2006 21:13:57 +0000 (21:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26429 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelDAGToDAG.cpp

index 9ef20da..3cf3671 100644 (file)
@@ -453,8 +453,11 @@ bool X86DAGToDAGISel::SelectLEAAddr(SDOperand N, SDOperand &Base,
   else
     AM.IndexReg = CurDAG->getRegister(0, MVT::i32);
 
-  if (AM.Scale > 1)
+  if (AM.Scale > 2) 
     Complexity += 2;
+  // Don't match just leal(,%reg,2). It's cheaper to do addl %reg, %reg
+  else if (AM.Scale > 1)
+    Complexity++;
 
   // FIXME: We are artificially lowering the criteria to turn ADD %reg, $GA
   // to a LEA. This is determined with some expermentation but is by no means