summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kuperstein <michael.m.kuperstein@intel.com>2015-02-12 14:17:35 +0000
committerMichael Kuperstein <michael.m.kuperstein@intel.com>2015-02-12 14:17:35 +0000
commitf4d1aca56808ba143da704fb51bdf0df52ca6fef (patch)
tree1467dda135c7db421a3f4d2016b16c416d86086c
parentb08862c4f0685023dd05ffc3c756aa6a5b50b049 (diff)
downloadbcm5719-llvm-f4d1aca56808ba143da704fb51bdf0df52ca6fef.tar.gz
bcm5719-llvm-f4d1aca56808ba143da704fb51bdf0df52ca6fef.zip
[X86] Call frame optimization - allow stack-relative movs to be folded into a push
Since we track esp precisely, there's no reason not to allow this. llvm-svn: 228924
-rw-r--r--llvm/lib/Target/X86/X86CallFrameOptimization.cpp6
-rw-r--r--llvm/test/CodeGen/X86/movtopush.ll22
2 files changed, 11 insertions, 17 deletions
diff --git a/llvm/lib/Target/X86/X86CallFrameOptimization.cpp b/llvm/lib/Target/X86/X86CallFrameOptimization.cpp
index c0c009b6b7a..1ede5c73f2b 100644
--- a/llvm/lib/Target/X86/X86CallFrameOptimization.cpp
+++ b/llvm/lib/Target/X86/X86CallFrameOptimization.cpp
@@ -469,12 +469,6 @@ MachineInstr *X86CallFrameOptimization::canFoldIntoRegPush(
DefMI->getParent() != FrameSetup->getParent())
return nullptr;
- // Be careful with movs that load from a stack slot, since it may get
- // resolved incorrectly.
- // TODO: Again, we already have the infrastructure, so this should work.
- if (!DefMI->getOperand(1).isReg())
- return nullptr;
-
// Now, make sure everything else up until the ADJCALLSTACK is a sequence
// of MOVs. To be less conservative would require duplicating a lot of the
// logic from PeepholeOptimizer.
diff --git a/llvm/test/CodeGen/X86/movtopush.ll b/llvm/test/CodeGen/X86/movtopush.ll
index b0cb91a782d..4a5d9037394 100644
--- a/llvm/test/CodeGen/X86/movtopush.ll
+++ b/llvm/test/CodeGen/X86/movtopush.ll
@@ -103,7 +103,8 @@ entry:
; NORMAL-NEXT: addl $16, %esp
define void @test3(i32 %k) optsize {
entry:
- call void @good(i32 %k, i32 2, i32 3, i32 4)
+ %f = add i32 %k, 1
+ call void @good(i32 %f, i32 2, i32 3, i32 4)
ret void
}
@@ -200,21 +201,20 @@ entry:
ret void
}
-; But we don't want to fold stack-relative loads into the push,
-; because the offset will be wrong
+; Fold stack-relative loads into the push, with correct offset
+; In particular, at the second push, %b was at 12(%esp) and
+; %a wast at 8(%esp), but the second push bumped %esp, so %a
+; is now it at 12(%esp)
; NORMAL-LABEL: test8:
-; NORMAL-NOT: subl {{.*}} %esp
-; NORMAL: movl 4(%esp), [[EAX:%e..]]
-; NORMAL-NEXT: pushl $4
-; NORMAL-NEXT: pushl [[EAX]]
-; NORMAL-NEXT: pushl $2
+; NORMAL: pushl $4
+; NORMAL-NEXT: pushl 12(%esp)
+; NORMAL-NEXT: pushl 12(%esp)
; NORMAL-NEXT: pushl $1
; NORMAL-NEXT: call
; NORMAL-NEXT: addl $16, %esp
-define void @test8(i32* %ptr) optsize {
+define void @test8(i32 %a, i32 %b) optsize {
entry:
- %val = ptrtoint i32* %ptr to i32
- call void @good(i32 1, i32 2, i32 %val, i32 4)
+ call void @good(i32 1, i32 %a, i32 %b, i32 4)
ret void
}
OpenPOWER on IntegriCloud