1 # Check that we can remove the redundant save of constant registers such as $zero
2 # RUN: llc -mtriple=mips64-unknown-freebsd %s -start-before=machine-cp -o - | FileCheck %s --check-prefix ASM
3 # RUN: llc -mtriple=mips64-unknown-freebsd %s -verify-machineinstrs -run-pass=machine-cp -o - | FileCheck %s
5 target triple = "mips64-unknown-freebsd"
6 define i32 @a() nounwind {
9 ; ASM-NEXT: daddiu $sp, $sp, -16
10 ; ASM-NEXT: sd $ra, 8($sp) # 8-byte Folded Spill
12 ; ASM-NEXT: move $4, $zero
13 ; ASM-NEXT: move $4, $zero
14 ; ASM-NEXT: ld $ra, 8($sp) # 8-byte Folded Reload
16 ; ASM-NEXT: daddiu $sp, $sp, 16
26 liveins: $a0_64, $t9_64, $ra_64, $fp_64, $gp_64
27 ; CHECK-LABEL: name: a
28 ; CHECK: liveins: $a0_64, $t9_64, $ra_64, $fp_64, $gp_64
30 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
31 ; CHECK-NEXT: $a0_64 = COPY $zero_64
32 ; CHECK-NEXT: JALR64Pseudo $t9_64, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit $gp_64, implicit-def $sp, implicit-def $v0
33 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
34 ; CHECK-NEXT: $a0_64 = COPY $zero_64
35 ; CHECK-NEXT: PseudoReturn64 undef $ra_64, implicit $v0_64, implicit killed $a0_64
36 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
37 renamable $s0_64 = COPY $zero_64
38 $a0_64 = COPY renamable $s0_64
39 JALR64Pseudo $t9_64, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit $gp_64, implicit-def $sp, implicit-def $v0
40 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
41 $a0_64 = COPY killed renamable $s0_64
42 PseudoReturn64 undef $ra_64, implicit $v0_64, implicit killed $a0_64