1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 2# RUN: llc -o - -mtriple=aarch64-unknown-unknown -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s | FileCheck %s --check-prefixes=CHECK,CHECK-PRE 3# RUN: llc -o - -mtriple=aarch64-unknown-unknown -run-pass=aarch64-postlegalizer-combiner -verify-machineinstrs %s | FileCheck %s --check-prefixes=CHECK,CHECK-POST 4 5--- 6name: test_combine_trunc_select 7legalized: true 8body: | 9 bb.1: 10 ; CHECK-PRE-LABEL: name: test_combine_trunc_select 11 ; CHECK-PRE: %cond:_(s32) = COPY $w0 12 ; CHECK-PRE-NEXT: %lhs:_(s64) = COPY $x0 13 ; CHECK-PRE-NEXT: %rhs:_(s64) = COPY $x0 14 ; CHECK-PRE-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s64) 15 ; CHECK-PRE-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC %rhs(s64) 16 ; CHECK-PRE-NEXT: %small:_(s32) = G_SELECT %cond(s32), [[TRUNC]], [[TRUNC1]] 17 ; CHECK-PRE-NEXT: $w0 = COPY %small(s32) 18 ; 19 ; CHECK-POST-LABEL: name: test_combine_trunc_select 20 ; CHECK-POST: %cond:_(s32) = COPY $w0 21 ; CHECK-POST-NEXT: %lhs:_(s64) = COPY $x0 22 ; CHECK-POST-NEXT: %rhs:_(s64) = COPY $x0 23 ; CHECK-POST-NEXT: %res:_(s64) = G_SELECT %cond(s32), %lhs, %rhs 24 ; CHECK-POST-NEXT: %small:_(s32) = G_TRUNC %res(s64) 25 ; CHECK-POST-NEXT: $w0 = COPY %small(s32) 26 %cond:_(s32) = COPY $w0 27 %lhs:_(s64) = COPY $x0 28 %rhs:_(s64) = COPY $x0 29 %res:_(s64) = G_SELECT %cond(s32), %lhs, %rhs 30 %small:_(s32) = G_TRUNC %res(s64) 31 $w0 = COPY %small(s32) 32... 33--- 34name: test_combine_zext_select 35legalized: true 36body: | 37 bb.1: 38 ; CHECK-PRE-LABEL: name: test_combine_zext_select 39 ; CHECK-PRE: %cond:_(s32) = COPY $w0 40 ; CHECK-PRE-NEXT: %lhs:_(s32) = COPY $w0 41 ; CHECK-PRE-NEXT: %rhs:_(s32) = COPY $w0 42 ; CHECK-PRE-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT %lhs(s32) 43 ; CHECK-PRE-NEXT: [[ZEXT1:%[0-9]+]]:_(s64) = G_ZEXT %rhs(s32) 44 ; CHECK-PRE-NEXT: %big:_(s64) = G_SELECT %cond(s32), [[ZEXT]], [[ZEXT1]] 45 ; CHECK-PRE-NEXT: $x0 = COPY %big(s64) 46 ; 47 ; CHECK-POST-LABEL: name: test_combine_zext_select 48 ; CHECK-POST: %cond:_(s32) = COPY $w0 49 ; CHECK-POST-NEXT: %lhs:_(s32) = COPY $w0 50 ; CHECK-POST-NEXT: %rhs:_(s32) = COPY $w0 51 ; CHECK-POST-NEXT: %res:_(s32) = G_SELECT %cond(s32), %lhs, %rhs 52 ; CHECK-POST-NEXT: %big:_(s64) = G_ZEXT %res(s32) 53 ; CHECK-POST-NEXT: $x0 = COPY %big(s64) 54 %cond:_(s32) = COPY $w0 55 %lhs:_(s32) = COPY $w0 56 %rhs:_(s32) = COPY $w0 57 %res:_(s32) = G_SELECT %cond(s32), %lhs, %rhs 58 %big:_(s64) = G_ZEXT %res(s32) 59 $x0 = COPY %big(s64) 60... 61--- 62name: test_combine_anyzext_select 63legalized: true 64body: | 65 bb.1: 66 ; CHECK-PRE-LABEL: name: test_combine_anyzext_select 67 ; CHECK-PRE: %cond:_(s32) = COPY $w0 68 ; CHECK-PRE-NEXT: %lhs:_(s32) = COPY $w0 69 ; CHECK-PRE-NEXT: %rhs:_(s32) = COPY $w0 70 ; CHECK-PRE-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT %lhs(s32) 71 ; CHECK-PRE-NEXT: [[ANYEXT1:%[0-9]+]]:_(s64) = G_ANYEXT %rhs(s32) 72 ; CHECK-PRE-NEXT: %big:_(s64) = G_SELECT %cond(s32), [[ANYEXT]], [[ANYEXT1]] 73 ; CHECK-PRE-NEXT: $x0 = COPY %big(s64) 74 ; 75 ; CHECK-POST-LABEL: name: test_combine_anyzext_select 76 ; CHECK-POST: %cond:_(s32) = COPY $w0 77 ; CHECK-POST-NEXT: %lhs:_(s32) = COPY $w0 78 ; CHECK-POST-NEXT: %rhs:_(s32) = COPY $w0 79 ; CHECK-POST-NEXT: %res:_(s32) = G_SELECT %cond(s32), %lhs, %rhs 80 ; CHECK-POST-NEXT: %big:_(s64) = G_ANYEXT %res(s32) 81 ; CHECK-POST-NEXT: $x0 = COPY %big(s64) 82 %cond:_(s32) = COPY $w0 83 %lhs:_(s32) = COPY $w0 84 %rhs:_(s32) = COPY $w0 85 %res:_(s32) = G_SELECT %cond(s32), %lhs, %rhs 86 %big:_(s64) = G_ANYEXT %res(s32) 87 $x0 = COPY %big(s64) 88... 89--- 90name: test_combine_anyzext_select_multi_use 91legalized: true 92body: | 93 bb.1: 94 ; CHECK-LABEL: name: test_combine_anyzext_select_multi_use 95 ; CHECK: %cond:_(s32) = COPY $w0 96 ; CHECK-NEXT: %lhs:_(s32) = COPY $w0 97 ; CHECK-NEXT: %rhs:_(s32) = COPY $w0 98 ; CHECK-NEXT: %res:_(s32) = G_SELECT %cond(s32), %lhs, %rhs 99 ; CHECK-NEXT: %big:_(s64) = G_ANYEXT %res(s32) 100 ; CHECK-NEXT: $x0 = COPY %big(s64) 101 ; CHECK-NEXT: $w0 = COPY %res(s32) 102 %cond:_(s32) = COPY $w0 103 %lhs:_(s32) = COPY $w0 104 %rhs:_(s32) = COPY $w0 105 %res:_(s32) = G_SELECT %cond(s32), %lhs, %rhs 106 %big:_(s64) = G_ANYEXT %res(s32) 107 $x0 = COPY %big(s64) 108 $w0 = COPY %res(s32) 109... 110--- 111name: test_combine_trunc_select_vector_out_of_budget 112legalized: true 113body: | 114 bb.1: 115 ; CHECK-LABEL: name: test_combine_trunc_select_vector_out_of_budget 116 ; CHECK: %cond:_(<2 x s32>) = COPY $x0 117 ; CHECK-NEXT: %arg1:_(s64) = COPY $x0 118 ; CHECK-NEXT: %arg2:_(s64) = COPY $x0 119 ; CHECK-NEXT: %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64) 120 ; CHECK-NEXT: %bv2:_(<2 x s64>) = G_BUILD_VECTOR %arg2(s64), %arg1(s64) 121 ; CHECK-NEXT: %res:_(<2 x s64>) = G_SELECT %cond(<2 x s32>), %bv, %bv2 122 ; CHECK-NEXT: %small:_(<2 x s32>) = G_TRUNC %res(<2 x s64>) 123 ; CHECK-NEXT: $x0 = COPY %small(<2 x s32>) 124 %cond:_(<2 x s32>) = COPY $x0 125 %arg1:_(s64) = COPY $x0 126 %arg2:_(s64) = COPY $x0 127 %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64) 128 %bv2:_(<2 x s64>) = G_BUILD_VECTOR %arg2(s64), %arg1(s64) 129 %res:_(<2 x s64>) = G_SELECT %cond(<2 x s32>), %bv, %bv2 130 %small:_(<2 x s32>) = G_TRUNC %res(<2 x s64>) 131 $x0 = COPY %small(<2 x s32>) 132... 133--- 134name: test_combine_trunc_build_vector 135legalized: true 136body: | 137 bb.1: 138 ; CHECK-LABEL: name: test_combine_trunc_build_vector 139 ; CHECK: %arg1:_(s64) = COPY $x0 140 ; CHECK-NEXT: %arg2:_(s64) = COPY $x0 141 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %arg1(s64) 142 ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC %arg2(s64) 143 ; CHECK-NEXT: %small:_(<2 x s32>) = G_BUILD_VECTOR [[TRUNC]](s32), [[TRUNC1]](s32) 144 ; CHECK-NEXT: $x0 = COPY %small(<2 x s32>) 145 %arg1:_(s64) = COPY $x0 146 %arg2:_(s64) = COPY $x0 147 %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64) 148 %small:_(<2 x s32>) = G_TRUNC %bv(<2 x s64>) 149 $x0 = COPY %small(<2 x s32>) 150... 151--- 152name: test_combine_zext_build_vector 153legalized: true 154body: | 155 bb.1: 156 ; CHECK-LABEL: name: test_combine_zext_build_vector 157 ; CHECK: %arg1:_(s32) = COPY $w0 158 ; CHECK-NEXT: %arg2:_(s32) = COPY $w0 159 ; CHECK-NEXT: %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) 160 ; CHECK-NEXT: %large:_(<2 x s64>) = G_ZEXT %bv(<2 x s32>) 161 ; CHECK-NEXT: $q0 = COPY %large(<2 x s64>) 162 %arg1:_(s32) = COPY $w0 163 %arg2:_(s32) = COPY $w0 164 %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) 165 %large:_(<2 x s64>) = G_ZEXT %bv(<2 x s32>) 166 $q0 = COPY %large(<2 x s64>) 167... 168--- 169name: test_combine_anyext_build_vector 170legalized: true 171body: | 172 bb.1: 173 ; CHECK-LABEL: name: test_combine_anyext_build_vector 174 ; CHECK: %arg1:_(s32) = COPY $w0 175 ; CHECK-NEXT: %arg2:_(s32) = COPY $w0 176 ; CHECK-NEXT: %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) 177 ; CHECK-NEXT: %large:_(<2 x s64>) = G_ANYEXT %bv(<2 x s32>) 178 ; CHECK-NEXT: $q0 = COPY %large(<2 x s64>) 179 %arg1:_(s32) = COPY $w0 180 %arg2:_(s32) = COPY $w0 181 %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) 182 %large:_(<2 x s64>) = G_ANYEXT %bv(<2 x s32>) 183 $q0 = COPY %large(<2 x s64>) 184... 185--- 186name: test_combine_sext_build_vector 187legalized: true 188body: | 189 bb.1: 190 ; CHECK-LABEL: name: test_combine_sext_build_vector 191 ; CHECK: %arg1:_(s32) = COPY $w0 192 ; CHECK-NEXT: %arg2:_(s32) = COPY $w0 193 ; CHECK-NEXT: %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) 194 ; CHECK-NEXT: %large:_(<2 x s64>) = G_SEXT %bv(<2 x s32>) 195 ; CHECK-NEXT: $q0 = COPY %large(<2 x s64>) 196 %arg1:_(s32) = COPY $w0 197 %arg2:_(s32) = COPY $w0 198 %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) 199 %large:_(<2 x s64>) = G_SEXT %bv(<2 x s32>) 200 $q0 = COPY %large(<2 x s64>) 201... 202--- 203name: test_combine_anyext_build_vector_multi_use 204legalized: true 205body: | 206 bb.1: 207 ; CHECK-LABEL: name: test_combine_anyext_build_vector_multi_use 208 ; CHECK: %arg1:_(s32) = COPY $w0 209 ; CHECK-NEXT: %arg2:_(s32) = COPY $w0 210 ; CHECK-NEXT: %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) 211 ; CHECK-NEXT: %large:_(<2 x s64>) = G_ANYEXT %bv(<2 x s32>) 212 ; CHECK-NEXT: $q0 = COPY %large(<2 x s64>) 213 ; CHECK-NEXT: $d0 = COPY %bv(<2 x s32>) 214 %arg1:_(s32) = COPY $w0 215 %arg2:_(s32) = COPY $w0 216 %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) 217 %large:_(<2 x s64>) = G_ANYEXT %bv(<2 x s32>) 218 $q0 = COPY %large(<2 x s64>) 219 $d0 = COPY %bv(<2 x s32>) 220... 221--- 222name: test_undef_ptrtoint 223legalized: true 224body: | 225 bb.1: 226 ; CHECK-LABEL: name: test_undef_ptrtoint 227 ; CHECK: [[DEF:%[0-9]+]]:_(<2 x s64>) = G_IMPLICIT_DEF 228 ; CHECK-NEXT: $q0 = COPY [[DEF]](<2 x s64>) 229 %0:_(<2 x p0>) = G_IMPLICIT_DEF 230 %1:_(<2 x s64>) = G_PTRTOINT %0(<2 x p0>) 231 $q0 = COPY %1(<2 x s64>) 232... 233--- 234name: test_undef_inttoptr 235legalized: true 236body: | 237 bb.1: 238 ; CHECK-LABEL: name: test_undef_inttoptr 239 ; CHECK: [[DEF:%[0-9]+]]:_(<2 x p0>) = G_IMPLICIT_DEF 240 ; CHECK-NEXT: $q0 = COPY [[DEF]](<2 x p0>) 241 %0:_(<2 x s64>) = G_IMPLICIT_DEF 242 %1:_(<2 x p0>) = G_INTTOPTR %0(<2 x s64>) 243 $q0 = COPY %1(<2 x p0>) 244