1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 2# RUN: llc -mtriple aarch64-unknown-unknown -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s 3# 4# Check that we can continue matching when we are in a situation where we will 5# emit a TB(N)Z. 6... 7--- 8name: fold_zext 9alignment: 4 10legalized: true 11regBankSelected: true 12tracksRegLiveness: true 13body: | 14 ; CHECK-LABEL: name: fold_zext 15 ; CHECK: bb.0: 16 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000) 17 ; CHECK: liveins: $x0 18 ; CHECK: %copy:gpr32 = COPY $w0 19 ; CHECK: TBNZW %copy, 3, %bb.1 20 ; CHECK: B %bb.0 21 ; CHECK: bb.1: 22 ; CHECK: RET_ReallyLR 23 bb.0: 24 successors: %bb.0, %bb.1 25 liveins: $x0 26 %copy:gpr(s32) = COPY $w0 27 %bit:gpr(s64) = G_CONSTANT i64 8 28 %zero:gpr(s64) = G_CONSTANT i64 0 29 %fold_me:gpr(s64) = G_ZEXT %copy(s32) 30 %and:gpr(s64) = G_AND %fold_me, %bit 31 %cmp:gpr(s32) = G_ICMP intpred(ne), %and(s64), %zero 32 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32) 33 G_BRCOND %cmp_trunc(s1), %bb.1 34 G_BR %bb.0 35 bb.1: 36 RET_ReallyLR 37... 38--- 39name: fold_anyext 40alignment: 4 41legalized: true 42regBankSelected: true 43tracksRegLiveness: true 44body: | 45 ; CHECK-LABEL: name: fold_anyext 46 ; CHECK: bb.0: 47 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000) 48 ; CHECK: liveins: $x0 49 ; CHECK: %copy:gpr32 = COPY $w0 50 ; CHECK: TBNZW %copy, 3, %bb.1 51 ; CHECK: B %bb.0 52 ; CHECK: bb.1: 53 ; CHECK: RET_ReallyLR 54 bb.0: 55 successors: %bb.0, %bb.1 56 liveins: $x0 57 %copy:gpr(s32) = COPY $w0 58 %bit:gpr(s64) = G_CONSTANT i64 8 59 %zero:gpr(s64) = G_CONSTANT i64 0 60 %fold_me:gpr(s64) = G_ANYEXT %copy(s32) 61 %and:gpr(s64) = G_AND %fold_me, %bit 62 %cmp:gpr(s32) = G_ICMP intpred(ne), %and(s64), %zero 63 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32) 64 G_BRCOND %cmp_trunc(s1), %bb.1 65 G_BR %bb.0 66 bb.1: 67 RET_ReallyLR 68... 69--- 70name: fold_multiple 71alignment: 4 72legalized: true 73regBankSelected: true 74tracksRegLiveness: true 75body: | 76 ; CHECK-LABEL: name: fold_multiple 77 ; CHECK: bb.0: 78 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000) 79 ; CHECK: liveins: $h0 80 ; CHECK: [[SUBREG_TO_REG:%[0-9]+]]:fpr32 = SUBREG_TO_REG 0, $h0, %subreg.hsub 81 ; CHECK: %copy:gpr32all = COPY [[SUBREG_TO_REG]] 82 ; CHECK: [[COPY:%[0-9]+]]:gpr32 = COPY %copy 83 ; CHECK: TBNZW [[COPY]], 3, %bb.1 84 ; CHECK: B %bb.0 85 ; CHECK: bb.1: 86 ; CHECK: RET_ReallyLR 87 bb.0: 88 successors: %bb.0, %bb.1 89 liveins: $h0 90 %copy:gpr(s16) = COPY $h0 91 %bit:gpr(s64) = G_CONSTANT i64 8 92 %zero:gpr(s64) = G_CONSTANT i64 0 93 %ext1:gpr(s32) = G_ZEXT %copy(s16) 94 %ext2:gpr(s64) = G_ANYEXT %ext1(s32) 95 %and:gpr(s64) = G_AND %ext2, %bit 96 %cmp:gpr(s32) = G_ICMP intpred(ne), %and(s64), %zero 97 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32) 98 G_BRCOND %cmp_trunc(s1), %bb.1 99 G_BR %bb.0 100 bb.1: 101 RET_ReallyLR 102... 103--- 104name: dont_fold_more_than_one_use 105alignment: 4 106legalized: true 107regBankSelected: true 108tracksRegLiveness: true 109body: | 110 ; CHECK-LABEL: name: dont_fold_more_than_one_use 111 ; CHECK: bb.0: 112 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000) 113 ; CHECK: liveins: $x0 114 ; CHECK: %copy:gpr32 = COPY $w0 115 ; CHECK: [[SUBREG_TO_REG:%[0-9]+]]:gpr64 = SUBREG_TO_REG 0, %copy, %subreg.sub_32 116 ; CHECK: %zext:gpr64 = UBFMXri [[SUBREG_TO_REG]], 0, 31 117 ; CHECK: [[COPY:%[0-9]+]]:gpr32all = COPY %zext.sub_32 118 ; CHECK: [[COPY1:%[0-9]+]]:gpr32 = COPY [[COPY]] 119 ; CHECK: TBNZW [[COPY1]], 3, %bb.1 120 ; CHECK: B %bb.0 121 ; CHECK: bb.1: 122 ; CHECK: $x0 = COPY %zext 123 ; CHECK: RET_ReallyLR implicit $x0 124 bb.0: 125 successors: %bb.0, %bb.1 126 liveins: $x0 127 %copy:gpr(s32) = COPY $w0 128 %bit:gpr(s64) = G_CONSTANT i64 8 129 %zero:gpr(s64) = G_CONSTANT i64 0 130 %zext:gpr(s64) = G_ZEXT %copy(s32) 131 %and:gpr(s64) = G_AND %zext, %bit 132 %cmp:gpr(s32) = G_ICMP intpred(ne), %and(s64), %zero 133 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32) 134 G_BRCOND %cmp_trunc(s1), %bb.1 135 G_BR %bb.0 136 bb.1: 137 $x0 = COPY %zext:gpr(s64) 138 RET_ReallyLR implicit $x0 139