diff options
| author | Matthias Braun <matze@braunis.de> | 2016-02-26 03:18:50 +0000 |
|---|---|---|
| committer | Matthias Braun <matze@braunis.de> | 2016-02-26 03:18:50 +0000 |
| commit | e39ff706851efee34063cf99fdde509ee5d95fd3 (patch) | |
| tree | 392c7588eebf421b67eb89851188c19368617b49 /llvm/test | |
| parent | e3fda8a19da30aec8687e66d3700a55e7acba847 (diff) | |
| download | bcm5719-llvm-e39ff706851efee34063cf99fdde509ee5d95fd3.tar.gz bcm5719-llvm-e39ff706851efee34063cf99fdde509ee5d95fd3.zip | |
MachineCopyPropagation: Keep scanning through instructions with regmasks
This also simplifies the code by removing the overly conservative
NoInterveningSideEffect() function. This function checked:
- That the two copies belong to the same block: We only process one
block at a time and clear our maps in between it is impossible to find a
copy from a different block.
- There is no terminator between the two copy instructions: This is not
allowed anyway (the MachineVerifier would complain)
- Does not have instructions with hasUnmodeledSideEffects() or isCall()
set: Even for those instructuction we must have all clobbers/defs of
registers explicit as an operand. If the register is explicitely
clobbered we would never come to the point of checking for
NoInterveningSideEffect() anyway.
(I also checked this with a temporary build of the test-suite with all
potentially failing conditions in NoInterveningSideEffect() turned into
asserts)
Differential Revision: http://reviews.llvm.org/D17474
llvm-svn: 261965
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/CodeGen/X86/machine-copy-prop.mir | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/llvm/test/CodeGen/X86/machine-copy-prop.mir b/llvm/test/CodeGen/X86/machine-copy-prop.mir index 85d38225a46..cf566edf253 100644 --- a/llvm/test/CodeGen/X86/machine-copy-prop.mir +++ b/llvm/test/CodeGen/X86/machine-copy-prop.mir @@ -1,13 +1,16 @@ -# RUN: llc -march=x86 -run-pass machine-cp -verify-machineinstrs -o /dev/null %s 2>&1 | FileCheck %s +# RUN: llc -march=x86 -run-pass machine-cp -o /dev/null %s 2>&1 | FileCheck %s --- | declare void @foo() define void @copyprop_remove_kill0() { ret void } define void @copyprop_remove_kill1() { ret void } define void @copyprop_remove_kill2() { ret void } + define void @copyprop0() { ret void } + define void @nocopyprop0() { ret void } + define void @nocopyprop1() { ret void } ... --- -# The second copy is redundand and will be removed, check that we also remove +# The second copy is redundant and will be removed, check that we also remove # the kill flag of intermediate instructions. # CHECK-LABEL: name: copyprop_remove_kill0 # CHECK: bb.0: @@ -24,7 +27,7 @@ body: | NOOP implicit %rax, implicit %rdi ... --- -# The second copy is redundand and will be removed, check that we also remove +# The second copy is redundant and will be removed, check that we also remove # the kill flag of intermediate instructions. # CHECK-LABEL: name: copyprop_remove_kill1 # CHECK: bb.0: @@ -41,7 +44,7 @@ body: | NOOP implicit %rax, implicit %rdi ... --- -# The second copy is redundand and will be removed, check that we also remove +# The second copy is redundant and will be removed, check that we also remove # the kill flag of intermediate instructions. # CHECK-LABEL: name: copyprop_remove_kill2 # CHECK: bb.0: @@ -57,3 +60,55 @@ body: | %di = COPY %ax NOOP implicit %rax, implicit %rdi ... +--- +# The second copy is redundant; the call preserves the source and dest register. +# CHECK-LABEL: name: copyprop0 +# CHECK: bb.0: +# CHECK-NEXT: %rax = COPY %rdi +# CHECK-NEXT: CALL64pcrel32 @foo, csr_64_rt_mostregs +# CHECK-NEXT: NOOP implicit %edi +# CHECK-NOT: COPY +# CHECK-NEXT: NOOP implicit %rax, implicit %rdi +name: copyprop0 +body: | + bb.0: + %rax = COPY %rdi + CALL64pcrel32 @foo, csr_64_rt_mostregs + NOOP implicit killed %edi + %rdi = COPY %rax + NOOP implicit %rax, implicit %rdi +... +--- +# The second copy is not redundant if the source register (%rax) is clobbered +# even if the dest (%rbp) is not. +# CHECK-LABEL: name: nocopyprop0 +# CHECK: bb.0: +# CHECK-NEXT: %rax = COPY %rbp +# CHECK-NEXT: CALL64pcrel32 @foo, csr_64, implicit %rax, implicit %rbp +# CHECK-NEXT: %rbp = COPY %rax +# CHECK-NEXT: NOOP implicit %rax, implicit %rbp +name: nocopyprop0 +body: | + bb.0: + %rax = COPY %rbp + CALL64pcrel32 @foo, csr_64, implicit %rax, implicit %rbp + %rbp = COPY %rax + NOOP implicit %rax, implicit %rbp +... +--- +# The second copy is not redundant if the dest register (%rax) is clobbered +# even if the source (%rbp) is not. +# CHECK-LABEL: name: nocopyprop1 +# CHECK: bb.0: +# CHECK-NEXT: %rbp = COPY %rax +# CHECK-NEXT: CALL64pcrel32 @foo, csr_64, implicit %rax, implicit %rbp +# CHECK-NEXT: %rax = COPY %rbp +# CHECK-NEXT: NOOP implicit %rax, implicit %rbp +name: nocopyprop1 +body: | + bb.0: + %rbp = COPY %rax + CALL64pcrel32 @foo, csr_64, implicit %rax, implicit %rbp + %rax = COPY %rbp + NOOP implicit %rax, implicit %rbp +... |

