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
24 liveins: $a0_64, $t9_64, $ra_64, $fp_64, $gp_64
25 ; CHECK-LABEL: name: a
26 ; CHECK: liveins: $a0_64, $t9_64, $ra_64, $fp_64, $gp_64
28 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
29 ; CHECK-NEXT: $a0_64 = COPY $zero_64
30 ; CHECK-NEXT: JALR64Pseudo $t9_64, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit $gp_64, implicit-def $sp, implicit-def $v0
31 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
32 ; CHECK-NEXT: $a0_64 = COPY $zero_64
33 ; CHECK-NEXT: PseudoReturn64 undef $ra_64, implicit $v0_64, implicit killed $a0_64
34 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
35 renamable $s0_64 = COPY $zero_64
36 $a0_64 = COPY renamable $s0_64
37 JALR64Pseudo $t9_64, csr_n64, implicit-def dead $ra, implicit $a0_64, implicit $gp_64, implicit-def $sp, implicit-def $v0
38 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
39 $a0_64 = COPY killed renamable $s0_64
40 PseudoReturn64 undef $ra_64, implicit $v0_64, implicit killed $a0_64