136 lines · plain
1# RUN: llc -mtriple=aarch64-apple-ios -run-pass=register-coalescer -verify-machineinstrs %s -o - | FileCheck %s2--- |3 declare void @f2()4 5 define void @func0() { ret void }6 define void @func1() { ret void }7 define void @func2() { ret void }8...9---10# Check coalescing of COPYs from reserved physregs.11# CHECK-LABEL: name: func012name: func013body: |14 bb.0:15 ; We usually should not coalesce copies from allocatable physregs.16 ; CHECK: %0:gpr32 = COPY $w717 ; CHECK: STRWui %0, $x1, 018 %0 : gpr32 = COPY $w719 STRWui %0, $x1, 020 21 ; It is fine to coalesce copies from reserved physregs22 ; CHECK-NOT: COPY23 ; CHECK: STRXui $fp, $x1, 024 %1 : gpr64 = COPY $fp25 STRXui %1, $x1, 026 27 ; It is not fine to coalesce copies from reserved physregs when they are28 ; clobbered.29 ; CHECK: %2:gpr64 = COPY $fp30 ; CHECK: STRXui %2, $x1, 031 %2 : gpr64 = COPY $fp32 $fp = SUBXri $fp, 4, 033 STRXui %2, $x1, 034 35 ; Is is fine to coalesce copies from constant physregs even when they are36 ; clobbered.37 ; CHECK-NOT: COPY38 ; CHECK: STRWui $wzr, $x139 %3 : gpr32 = COPY $wzr40 dead $wzr = SUBSWri $w1, 0, 0, implicit-def $nzcv41 STRWui %3, $x1, 042 43 ; Is is fine to coalesce copies from constant physregs even when they are44 ; clobbered.45 ; CHECK-NOT: COPY46 ; CHECK: STRXui $xzr, $x147 %4 : gpr64 = COPY $xzr48 dead $wzr = SUBSWri $w1, 0, 0, implicit-def $nzcv49 STRXui %4, $x1, 050 51 ; Coalescing COPYs into constant physregs.52 ; CHECK: $wzr = SUBSWri $w1, 0, 053 %5 : gpr32 = SUBSWri $w1, 0, 0, implicit-def $nzcv54 $wzr = COPY %555 56 ; Only coalesce when the source register is reserved as a whole (this is57 ; a limitation of the current code which cannot update liveness information58 ; of the non-reserved part).59 ; CHECK: %6:xseqpairsclass = COPY $x28_fp60 ; CHECK: HINT 0, implicit %661 %6 : xseqpairsclass = COPY $x28_fp62 HINT 0, implicit %663 64 ; It is not fine to coalesce copies from reserved physregs when they are65 ; clobbered by the regmask on a call.66 ; CHECK: %7:gpr64 = COPY $x1867 ; CHECK: BL @f2, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp68 ; CHECK: STRXui %7, $x1, 069 70 ; Need a def of x18 so that it's not deduced as "constant".71 $x18 = COPY $xzr72 %7 : gpr64 = COPY $x1873 BL @f2, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp74 STRXui %7, $x1, 075 76 ; This can be coalesced.77 ; CHECK: $fp = SUBXri $fp, 4, 078 %8 : gpr64sp = SUBXri $fp, 4, 079 $fp = COPY %880 81 ; Cannot coalesce when there are reads of the physreg.82 ; CHECK-NOT: $fp = SUBXri $fp, 8, 083 ; CHECK: %9:gpr64sp = SUBXri $fp, 8, 084 ; CHECK: STRXui $fp, $fp, 085 ; CHECK: $fp = COPY %986 %9 : gpr64sp = SUBXri $fp, 8, 087 STRXui $fp, $fp, 088 $fp = COPY %989...90---91# Check coalescing of COPYs from reserved physregs.92# CHECK-LABEL: name: func193name: func194body: |95 bb.0:96 ; Cannot coalesce physreg because we have reads on other CFG paths (we97 ; currently abort for any control flow)98 ; CHECK-NOT: $fp = SUBXri99 ; CHECK: %0:gpr64sp = SUBXri $fp, 12, 0100 ; CHECK: CBZX undef $x0, %bb.1101 ; CHECK: B %bb.2102 %0 : gpr64sp = SUBXri $fp, 12, 0103 CBZX undef $x0, %bb.1104 B %bb.2105 106 bb.1:107 $fp = COPY %0108 RET_ReallyLR109 110 bb.2:111 STRXui $fp, $fp, 0112 RET_ReallyLR113...114---115# CHECK-LABEL: name: func2116name: func2117body: |118 bb.0:119 ; We can coalesce copies from physreg to vreg across multiple blocks.120 ; CHECK-NOT: COPY121 ; CHECK: CBZX undef $x0, %bb.1122 ; CHECK-NEXT: B %bb.2123 %0 : gpr64sp = COPY $fp124 CBZX undef $x0, %bb.1125 B %bb.2126 127 bb.1:128 ; CHECK: STRXui undef $x0, $fp, 0129 ; CHECK-NEXT: RET_ReallyLR130 STRXui undef $x0, %0, 0131 RET_ReallyLR132 133 bb.2:134 RET_ReallyLR135...136