Handle (store &GV -> mem) as a store immediate. This often occurs for
authorChris Lattner <sabre@nondot.org>
Thu, 21 Apr 2005 19:03:24 +0000 (19:03 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 21 Apr 2005 19:03:24 +0000 (19:03 +0000)
printf format strings and other stuff.  Instead of generating this:

        movl $l1__2E_str_1, %eax
        movl %eax, (%esp)

we now emit:

        movl $l1__2E_str_1, (%esp)

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

lib/Target/X86/X86ISelPattern.cpp

index 949cda96882b138af7906211333f71d65d35b2ea..262e0281285f66c0b6e55fdee566e7d04ab4d286 100644 (file)
@@ -3120,6 +3120,20 @@ void ISel::Select(SDOperand N) {
         addFullAddress(BuildMI(BB, Opc, 4+1), AM).addImm(CN->getValue());
         return;
       }
+    } else if (GlobalAddressSDNode *GA =
+                      dyn_cast<GlobalAddressSDNode>(N.getOperand(1))) {
+      assert(GA->getValueType(0) == MVT::i32 && "Bad pointer operand");
+
+      if (getRegPressure(N.getOperand(0)) > getRegPressure(N.getOperand(2))) {
+        Select(N.getOperand(0));
+        SelectAddress(N.getOperand(2), AM);
+      } else {
+        SelectAddress(N.getOperand(2), AM);
+        Select(N.getOperand(0));
+      }
+      addFullAddress(BuildMI(BB, X86::MOV32mi, 4+1),
+                     AM).addGlobalAddress(GA->getGlobal());
+      return;
     }
 
     // Check to see if this is a load/op/store combination.