Rely on the code in MatchAddress to do this work. Otherwise we fail to
authorChris Lattner <sabre@nondot.org>
Tue, 18 Jan 2005 02:25:52 +0000 (02:25 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 18 Jan 2005 02:25:52 +0000 (02:25 +0000)
match (X+Y)+(Z << 1), because we match the X+Y first, consuming the index
register, then there is no place to put the Z.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19652 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelPattern.cpp

index 4dc29ea6fd59034e8226d578635fe9fe1d96e7e3..47aa527c7ac78d368b2efef6e9db134a9cef46dd 100644 (file)
@@ -1579,18 +1579,20 @@ unsigned ISel::SelectExpr(SDOperand N) {
 
     // See if we can codegen this as an LEA to fold operations together.
     if (N.getValueType() == MVT::i32) {
+      ExprMap.erase(N);
       X86ISelAddressMode AM;
-      if (!MatchAddress(Op0, AM) && !MatchAddress(Op1, AM)) {
-       // If this is not just an add, emit the LEA.  For a simple add (like
-       // reg+reg or reg+imm), we just emit an add.  It might be a good idea to
-       // leave this as LEA, then peephole it to 'ADD' after two address elim
-       // happens.
-        if (AM.Scale != 1 || AM.BaseType == X86ISelAddressMode::FrameIndexBase||
-            AM.GV || (AM.Base.Reg.Val && AM.IndexReg.Val && AM.Disp)) {
-          X86AddressMode XAM = SelectAddrExprs(AM);
-          addFullAddress(BuildMI(BB, X86::LEA32r, 4, Result), XAM);
-          return Result;
-        }
+      MatchAddress(N, AM);
+      ExprMap[N] = Result;
+
+      // If this is not just an add, emit the LEA.  For a simple add (like
+      // reg+reg or reg+imm), we just emit an add.  It might be a good idea to
+      // leave this as LEA, then peephole it to 'ADD' after two address elim
+      // happens.
+      if (AM.Scale != 1 || AM.BaseType == X86ISelAddressMode::FrameIndexBase||
+          AM.GV || (AM.Base.Reg.Val && AM.IndexReg.Val && AM.Disp)) {
+        X86AddressMode XAM = SelectAddrExprs(AM);
+        addFullAddress(BuildMI(BB, X86::LEA32r, 4, Result), XAM);
+        return Result;
       }
     }