# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # RUN: llc -o - -mtriple=aarch64-unknown-unknown -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s | FileCheck %s --check-prefixes=CHECK,CHECK-PRE # RUN: llc -o - -mtriple=aarch64-unknown-unknown -run-pass=aarch64-postlegalizer-combiner -verify-machineinstrs %s | FileCheck %s --check-prefixes=CHECK,CHECK-POST --- name: test_combine_trunc_select legalized: true body: | bb.1: ; CHECK-PRE-LABEL: name: test_combine_trunc_select ; CHECK-PRE: %cond:_(s32) = COPY $w0 ; CHECK-PRE-NEXT: %lhs:_(s64) = COPY $x0 ; CHECK-PRE-NEXT: %rhs:_(s64) = COPY $x0 ; CHECK-PRE-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s64) ; CHECK-PRE-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC %rhs(s64) ; CHECK-PRE-NEXT: %small:_(s32) = G_SELECT %cond(s32), [[TRUNC]], [[TRUNC1]] ; CHECK-PRE-NEXT: $w0 = COPY %small(s32) ; ; CHECK-POST-LABEL: name: test_combine_trunc_select ; CHECK-POST: %cond:_(s32) = COPY $w0 ; CHECK-POST-NEXT: %lhs:_(s64) = COPY $x0 ; CHECK-POST-NEXT: %rhs:_(s64) = COPY $x0 ; CHECK-POST-NEXT: %res:_(s64) = G_SELECT %cond(s32), %lhs, %rhs ; CHECK-POST-NEXT: %small:_(s32) = G_TRUNC %res(s64) ; CHECK-POST-NEXT: $w0 = COPY %small(s32) %cond:_(s32) = COPY $w0 %lhs:_(s64) = COPY $x0 %rhs:_(s64) = COPY $x0 %res:_(s64) = G_SELECT %cond(s32), %lhs, %rhs %small:_(s32) = G_TRUNC %res(s64) $w0 = COPY %small(s32) ... --- name: test_combine_zext_select legalized: true body: | bb.1: ; CHECK-PRE-LABEL: name: test_combine_zext_select ; CHECK-PRE: %cond:_(s32) = COPY $w0 ; CHECK-PRE-NEXT: %lhs:_(s32) = COPY $w0 ; CHECK-PRE-NEXT: %rhs:_(s32) = COPY $w0 ; CHECK-PRE-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT %lhs(s32) ; CHECK-PRE-NEXT: [[ZEXT1:%[0-9]+]]:_(s64) = G_ZEXT %rhs(s32) ; CHECK-PRE-NEXT: %big:_(s64) = G_SELECT %cond(s32), [[ZEXT]], [[ZEXT1]] ; CHECK-PRE-NEXT: $x0 = COPY %big(s64) ; ; CHECK-POST-LABEL: name: test_combine_zext_select ; CHECK-POST: %cond:_(s32) = COPY $w0 ; CHECK-POST-NEXT: %lhs:_(s32) = COPY $w0 ; CHECK-POST-NEXT: %rhs:_(s32) = COPY $w0 ; CHECK-POST-NEXT: %res:_(s32) = G_SELECT %cond(s32), %lhs, %rhs ; CHECK-POST-NEXT: %big:_(s64) = G_ZEXT %res(s32) ; CHECK-POST-NEXT: $x0 = COPY %big(s64) %cond:_(s32) = COPY $w0 %lhs:_(s32) = COPY $w0 %rhs:_(s32) = COPY $w0 %res:_(s32) = G_SELECT %cond(s32), %lhs, %rhs %big:_(s64) = G_ZEXT %res(s32) $x0 = COPY %big(s64) ... --- name: test_combine_anyzext_select legalized: true body: | bb.1: ; CHECK-PRE-LABEL: name: test_combine_anyzext_select ; CHECK-PRE: %cond:_(s32) = COPY $w0 ; CHECK-PRE-NEXT: %lhs:_(s32) = COPY $w0 ; CHECK-PRE-NEXT: %rhs:_(s32) = COPY $w0 ; CHECK-PRE-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT %lhs(s32) ; CHECK-PRE-NEXT: [[ANYEXT1:%[0-9]+]]:_(s64) = G_ANYEXT %rhs(s32) ; CHECK-PRE-NEXT: %big:_(s64) = G_SELECT %cond(s32), [[ANYEXT]], [[ANYEXT1]] ; CHECK-PRE-NEXT: $x0 = COPY %big(s64) ; ; CHECK-POST-LABEL: name: test_combine_anyzext_select ; CHECK-POST: %cond:_(s32) = COPY $w0 ; CHECK-POST-NEXT: %lhs:_(s32) = COPY $w0 ; CHECK-POST-NEXT: %rhs:_(s32) = COPY $w0 ; CHECK-POST-NEXT: %res:_(s32) = G_SELECT %cond(s32), %lhs, %rhs ; CHECK-POST-NEXT: %big:_(s64) = G_ANYEXT %res(s32) ; CHECK-POST-NEXT: $x0 = COPY %big(s64) %cond:_(s32) = COPY $w0 %lhs:_(s32) = COPY $w0 %rhs:_(s32) = COPY $w0 %res:_(s32) = G_SELECT %cond(s32), %lhs, %rhs %big:_(s64) = G_ANYEXT %res(s32) $x0 = COPY %big(s64) ... --- name: test_combine_anyzext_select_multi_use legalized: true body: | bb.1: ; CHECK-LABEL: name: test_combine_anyzext_select_multi_use ; CHECK: %cond:_(s32) = COPY $w0 ; CHECK-NEXT: %lhs:_(s32) = COPY $w0 ; CHECK-NEXT: %rhs:_(s32) = COPY $w0 ; CHECK-NEXT: %res:_(s32) = G_SELECT %cond(s32), %lhs, %rhs ; CHECK-NEXT: %big:_(s64) = G_ANYEXT %res(s32) ; CHECK-NEXT: $x0 = COPY %big(s64) ; CHECK-NEXT: $w0 = COPY %res(s32) %cond:_(s32) = COPY $w0 %lhs:_(s32) = COPY $w0 %rhs:_(s32) = COPY $w0 %res:_(s32) = G_SELECT %cond(s32), %lhs, %rhs %big:_(s64) = G_ANYEXT %res(s32) $x0 = COPY %big(s64) $w0 = COPY %res(s32) ... --- name: test_combine_trunc_select_vector_out_of_budget legalized: true body: | bb.1: ; CHECK-LABEL: name: test_combine_trunc_select_vector_out_of_budget ; CHECK: %cond:_(<2 x s32>) = COPY $x0 ; CHECK-NEXT: %arg1:_(s64) = COPY $x0 ; CHECK-NEXT: %arg2:_(s64) = COPY $x0 ; CHECK-NEXT: %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64) ; CHECK-NEXT: %bv2:_(<2 x s64>) = G_BUILD_VECTOR %arg2(s64), %arg1(s64) ; CHECK-NEXT: %res:_(<2 x s64>) = G_SELECT %cond(<2 x s32>), %bv, %bv2 ; CHECK-NEXT: %small:_(<2 x s32>) = G_TRUNC %res(<2 x s64>) ; CHECK-NEXT: $x0 = COPY %small(<2 x s32>) %cond:_(<2 x s32>) = COPY $x0 %arg1:_(s64) = COPY $x0 %arg2:_(s64) = COPY $x0 %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64) %bv2:_(<2 x s64>) = G_BUILD_VECTOR %arg2(s64), %arg1(s64) %res:_(<2 x s64>) = G_SELECT %cond(<2 x s32>), %bv, %bv2 %small:_(<2 x s32>) = G_TRUNC %res(<2 x s64>) $x0 = COPY %small(<2 x s32>) ... --- name: test_combine_trunc_build_vector legalized: true body: | bb.1: ; CHECK-LABEL: name: test_combine_trunc_build_vector ; CHECK: %arg1:_(s64) = COPY $x0 ; CHECK-NEXT: %arg2:_(s64) = COPY $x0 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %arg1(s64) ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC %arg2(s64) ; CHECK-NEXT: %small:_(<2 x s32>) = G_BUILD_VECTOR [[TRUNC]](s32), [[TRUNC1]](s32) ; CHECK-NEXT: $x0 = COPY %small(<2 x s32>) %arg1:_(s64) = COPY $x0 %arg2:_(s64) = COPY $x0 %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64) %small:_(<2 x s32>) = G_TRUNC %bv(<2 x s64>) $x0 = COPY %small(<2 x s32>) ... --- name: test_combine_zext_build_vector legalized: true body: | bb.1: ; CHECK-LABEL: name: test_combine_zext_build_vector ; CHECK: %arg1:_(s32) = COPY $w0 ; CHECK-NEXT: %arg2:_(s32) = COPY $w0 ; CHECK-NEXT: %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) ; CHECK-NEXT: %large:_(<2 x s64>) = G_ZEXT %bv(<2 x s32>) ; CHECK-NEXT: $q0 = COPY %large(<2 x s64>) %arg1:_(s32) = COPY $w0 %arg2:_(s32) = COPY $w0 %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) %large:_(<2 x s64>) = G_ZEXT %bv(<2 x s32>) $q0 = COPY %large(<2 x s64>) ... --- name: test_combine_anyext_build_vector legalized: true body: | bb.1: ; CHECK-LABEL: name: test_combine_anyext_build_vector ; CHECK: %arg1:_(s32) = COPY $w0 ; CHECK-NEXT: %arg2:_(s32) = COPY $w0 ; CHECK-NEXT: %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) ; CHECK-NEXT: %large:_(<2 x s64>) = G_ANYEXT %bv(<2 x s32>) ; CHECK-NEXT: $q0 = COPY %large(<2 x s64>) %arg1:_(s32) = COPY $w0 %arg2:_(s32) = COPY $w0 %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) %large:_(<2 x s64>) = G_ANYEXT %bv(<2 x s32>) $q0 = COPY %large(<2 x s64>) ... --- name: test_combine_sext_build_vector legalized: true body: | bb.1: ; CHECK-LABEL: name: test_combine_sext_build_vector ; CHECK: %arg1:_(s32) = COPY $w0 ; CHECK-NEXT: %arg2:_(s32) = COPY $w0 ; CHECK-NEXT: %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) ; CHECK-NEXT: %large:_(<2 x s64>) = G_SEXT %bv(<2 x s32>) ; CHECK-NEXT: $q0 = COPY %large(<2 x s64>) %arg1:_(s32) = COPY $w0 %arg2:_(s32) = COPY $w0 %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) %large:_(<2 x s64>) = G_SEXT %bv(<2 x s32>) $q0 = COPY %large(<2 x s64>) ... --- name: test_combine_anyext_build_vector_multi_use legalized: true body: | bb.1: ; CHECK-LABEL: name: test_combine_anyext_build_vector_multi_use ; CHECK: %arg1:_(s32) = COPY $w0 ; CHECK-NEXT: %arg2:_(s32) = COPY $w0 ; CHECK-NEXT: %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) ; CHECK-NEXT: %large:_(<2 x s64>) = G_ANYEXT %bv(<2 x s32>) ; CHECK-NEXT: $q0 = COPY %large(<2 x s64>) ; CHECK-NEXT: $d0 = COPY %bv(<2 x s32>) %arg1:_(s32) = COPY $w0 %arg2:_(s32) = COPY $w0 %bv:_(<2 x s32>) = G_BUILD_VECTOR %arg1(s32), %arg2(s32) %large:_(<2 x s64>) = G_ANYEXT %bv(<2 x s32>) $q0 = COPY %large(<2 x s64>) $d0 = COPY %bv(<2 x s32>) ... --- name: test_undef_ptrtoint legalized: true body: | bb.1: ; CHECK-LABEL: name: test_undef_ptrtoint ; CHECK: [[DEF:%[0-9]+]]:_(<2 x s64>) = G_IMPLICIT_DEF ; CHECK-NEXT: $q0 = COPY [[DEF]](<2 x s64>) %0:_(<2 x p0>) = G_IMPLICIT_DEF %1:_(<2 x s64>) = G_PTRTOINT %0(<2 x p0>) $q0 = COPY %1(<2 x s64>) ... --- name: test_undef_inttoptr legalized: true body: | bb.1: ; CHECK-LABEL: name: test_undef_inttoptr ; CHECK: [[DEF:%[0-9]+]]:_(<2 x p0>) = G_IMPLICIT_DEF ; CHECK-NEXT: $q0 = COPY [[DEF]](<2 x p0>) %0:_(<2 x s64>) = G_IMPLICIT_DEF %1:_(<2 x p0>) = G_INTTOPTR %0(<2 x s64>) $q0 = COPY %1(<2 x p0>)