1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64-apple-ios -run-pass=aarch64-prelegalizer-combiner %s -o - | FileCheck %s
4 # Check that we canonicalize concat_vectors(build_vector, build_vector)
7 name: concat_to_build_vector
8 tracksRegLiveness: true
11 liveins: $x0, $x1, $x2, $x3
13 ; CHECK-LABEL: name: concat_to_build_vector
14 ; CHECK: liveins: $x0, $x1, $x2, $x3
16 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
17 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
18 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
19 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
20 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s64>) = G_BUILD_VECTOR [[COPY]](s64), [[COPY1]](s64), [[COPY2]](s64), [[COPY3]](s64)
21 ; CHECK-NEXT: RET_ReallyLR implicit [[BUILD_VECTOR]](<4 x s64>)
26 %4:_(<2 x s64>) = G_BUILD_VECTOR %0(s64), %1
27 %5:_(<2 x s64>) = G_BUILD_VECTOR %2(s64), %3
28 %6:_(<4 x s64>) = G_CONCAT_VECTORS %4(<2 x s64>), %5
29 RET_ReallyLR implicit %6
31 # Same test as concat_to_build_vector but with pointer types.
33 name: concat_to_build_vector_ptr
34 tracksRegLiveness: true
37 liveins: $x0, $x1, $x2, $x3
39 ; CHECK-LABEL: name: concat_to_build_vector_ptr
40 ; CHECK: liveins: $x0, $x1, $x2, $x3
42 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
43 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
44 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(p0) = COPY $x2
45 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(p0) = COPY $x3
46 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x p0>) = G_BUILD_VECTOR [[COPY]](p0), [[COPY1]](p0), [[COPY2]](p0), [[COPY3]](p0)
47 ; CHECK-NEXT: RET_ReallyLR implicit [[BUILD_VECTOR]](<4 x p0>)
52 %4:_(<2 x p0>) = G_BUILD_VECTOR %0(p0), %1
53 %5:_(<2 x p0>) = G_BUILD_VECTOR %2(p0), %3
54 %6:_(<4 x p0>) = G_CONCAT_VECTORS %4(<2 x p0>), %5
55 RET_ReallyLR implicit %6
57 # Check that we canonicalize concat_vectors(undef, undef) into undef.
60 tracksRegLiveness: true
63 ; CHECK-LABEL: name: concat_to_undef
64 ; CHECK: [[DEF:%[0-9]+]]:_(<4 x s64>) = G_IMPLICIT_DEF
65 ; CHECK-NEXT: RET_ReallyLR implicit [[DEF]](<4 x s64>)
66 %4:_(<2 x s64>) = G_IMPLICIT_DEF
67 %5:_(<2 x s64>) = G_IMPLICIT_DEF
68 %6:_(<4 x s64>) = G_CONCAT_VECTORS %4(<2 x s64>), %5
69 RET_ReallyLR implicit %6
71 # Check that when combining concat_vectors(build_vector, undef) into
72 # build_vector, we correctly break the undef vector into a sequence
75 name: concat_to_build_vector_with_undef
76 tracksRegLiveness: true
81 ; CHECK-LABEL: name: concat_to_build_vector_with_undef
82 ; CHECK: liveins: $x0, $x1
84 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
85 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
86 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
87 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s64>) = G_BUILD_VECTOR [[COPY]](s64), [[COPY1]](s64), [[DEF]](s64), [[DEF]](s64)
88 ; CHECK-NEXT: RET_ReallyLR implicit [[BUILD_VECTOR]](<4 x s64>)
91 %4:_(<2 x s64>) = G_BUILD_VECTOR %0(s64), %1
92 %5:_(<2 x s64>) = G_IMPLICIT_DEF
93 %6:_(<4 x s64>) = G_CONCAT_VECTORS %4(<2 x s64>), %5
94 RET_ReallyLR implicit %6
96 # Same as concat_to_build_vector_with_undef but with pointer types.
98 name: concat_to_build_vector_with_undef_ptr
99 tracksRegLiveness: true
104 ; CHECK-LABEL: name: concat_to_build_vector_with_undef_ptr
105 ; CHECK: liveins: $x0, $x1
107 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
108 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
109 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(p0) = G_IMPLICIT_DEF
110 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x p0>) = G_BUILD_VECTOR [[COPY]](p0), [[COPY1]](p0), [[DEF]](p0), [[DEF]](p0)
111 ; CHECK-NEXT: RET_ReallyLR implicit [[BUILD_VECTOR]](<4 x p0>)
114 %4:_(<2 x p0>) = G_BUILD_VECTOR %0(p0), %1
115 %5:_(<2 x p0>) = G_IMPLICIT_DEF
116 %6:_(<4 x p0>) = G_CONCAT_VECTORS %4(<2 x p0>), %5
117 RET_ReallyLR implicit %6
119 # Check that we keep a concat_vectors as soon as one of the operand is
120 # not undef or build_vector. I.e., we cannot flatten the concat_vectors.
122 name: concat_to_build_vector_negative_test
123 tracksRegLiveness: true
128 ; CHECK-LABEL: name: concat_to_build_vector_negative_test
129 ; CHECK: liveins: $q0
131 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0
132 ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<2 x s64>) = G_IMPLICIT_DEF
133 ; CHECK-NEXT: [[CONCAT_VECTORS:%[0-9]+]]:_(<4 x s64>) = G_CONCAT_VECTORS [[COPY]](<2 x s64>), [[DEF]](<2 x s64>)
134 ; CHECK-NEXT: RET_ReallyLR implicit [[CONCAT_VECTORS]](<4 x s64>)
135 %4:_(<2 x s64>) = COPY $q0
136 %5:_(<2 x s64>) = G_IMPLICIT_DEF
137 %6:_(<4 x s64>) = G_CONCAT_VECTORS %4(<2 x s64>), %5
138 RET_ReallyLR implicit %6