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
15 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
16 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
17 ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
18 ; CHECK: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
19 ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s64>) = G_BUILD_VECTOR [[COPY]](s64), [[COPY1]](s64), [[COPY2]](s64), [[COPY3]](s64)
20 ; CHECK: RET_ReallyLR implicit [[BUILD_VECTOR]](<4 x s64>)
25 %4:_(<2 x s64>) = G_BUILD_VECTOR %0(s64), %1
26 %5:_(<2 x s64>) = G_BUILD_VECTOR %2(s64), %3
27 %6:_(<4 x s64>) = G_CONCAT_VECTORS %4(<2 x s64>), %5
28 RET_ReallyLR implicit %6
30 # Same test as concat_to_build_vector but with pointer types.
32 name: concat_to_build_vector_ptr
33 tracksRegLiveness: true
36 liveins: $x0, $x1, $x2, $x3
38 ; CHECK-LABEL: name: concat_to_build_vector_ptr
39 ; CHECK: liveins: $x0, $x1, $x2, $x3
40 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
41 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
42 ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY $x2
43 ; CHECK: [[COPY3:%[0-9]+]]:_(p0) = COPY $x3
44 ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x p0>) = G_BUILD_VECTOR [[COPY]](p0), [[COPY1]](p0), [[COPY2]](p0), [[COPY3]](p0)
45 ; CHECK: RET_ReallyLR implicit [[BUILD_VECTOR]](<4 x p0>)
50 %4:_(<2 x p0>) = G_BUILD_VECTOR %0(p0), %1
51 %5:_(<2 x p0>) = G_BUILD_VECTOR %2(p0), %3
52 %6:_(<4 x p0>) = G_CONCAT_VECTORS %4(<2 x p0>), %5
53 RET_ReallyLR implicit %6
55 # Check that we canonicalize concat_vectors(undef, undef) into undef.
58 tracksRegLiveness: true
61 ; CHECK-LABEL: name: concat_to_undef
62 ; CHECK: [[DEF:%[0-9]+]]:_(<4 x s64>) = G_IMPLICIT_DEF
63 ; CHECK: RET_ReallyLR implicit [[DEF]](<4 x s64>)
64 %4:_(<2 x s64>) = G_IMPLICIT_DEF
65 %5:_(<2 x s64>) = G_IMPLICIT_DEF
66 %6:_(<4 x s64>) = G_CONCAT_VECTORS %4(<2 x s64>), %5
67 RET_ReallyLR implicit %6
69 # Check that when combining concat_vectors(build_vector, undef) into
70 # build_vector, we correctly break the undef vector into a sequence
73 name: concat_to_build_vector_with_undef
74 tracksRegLiveness: true
79 ; CHECK-LABEL: name: concat_to_build_vector_with_undef
80 ; CHECK: liveins: $x0, $x1
81 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
82 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
83 ; CHECK: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
84 ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s64>) = G_BUILD_VECTOR [[COPY]](s64), [[COPY1]](s64), [[DEF]](s64), [[DEF]](s64)
85 ; CHECK: RET_ReallyLR implicit [[BUILD_VECTOR]](<4 x s64>)
88 %4:_(<2 x s64>) = G_BUILD_VECTOR %0(s64), %1
89 %5:_(<2 x s64>) = G_IMPLICIT_DEF
90 %6:_(<4 x s64>) = G_CONCAT_VECTORS %4(<2 x s64>), %5
91 RET_ReallyLR implicit %6
93 # Same as concat_to_build_vector_with_undef but with pointer types.
95 name: concat_to_build_vector_with_undef_ptr
96 tracksRegLiveness: true
101 ; CHECK-LABEL: name: concat_to_build_vector_with_undef_ptr
102 ; CHECK: liveins: $x0, $x1
103 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
104 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
105 ; CHECK: [[DEF:%[0-9]+]]:_(p0) = G_IMPLICIT_DEF
106 ; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x p0>) = G_BUILD_VECTOR [[COPY]](p0), [[COPY1]](p0), [[DEF]](p0), [[DEF]](p0)
107 ; CHECK: RET_ReallyLR implicit [[BUILD_VECTOR]](<4 x p0>)
110 %4:_(<2 x p0>) = G_BUILD_VECTOR %0(p0), %1
111 %5:_(<2 x p0>) = G_IMPLICIT_DEF
112 %6:_(<4 x p0>) = G_CONCAT_VECTORS %4(<2 x p0>), %5
113 RET_ReallyLR implicit %6
115 # Check that we keep a concat_vectors as soon as one of the operand is
116 # not undef or build_vector. I.e., we cannot flatten the concat_vectors.
118 name: concat_to_build_vector_negative_test
119 tracksRegLiveness: true
124 ; CHECK-LABEL: name: concat_to_build_vector_negative_test
125 ; CHECK: liveins: $x0, $x1
126 ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
127 ; CHECK: [[DEF:%[0-9]+]]:_(<2 x s64>) = G_IMPLICIT_DEF
128 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
129 ; CHECK: [[IVEC:%[0-9]+]]:_(<2 x s64>) = G_INSERT_VECTOR_ELT [[DEF]], [[COPY]](s64), [[C]](s32)
130 ; CHECK: [[DEF1:%[0-9]+]]:_(<2 x s64>) = G_IMPLICIT_DEF
131 ; CHECK: [[CONCAT_VECTORS:%[0-9]+]]:_(<4 x s64>) = G_CONCAT_VECTORS [[IVEC]](<2 x s64>), [[DEF1]](<2 x s64>)
132 ; CHECK: RET_ReallyLR implicit [[CONCAT_VECTORS]](<4 x s64>)
135 %2:_(<2 x s64>) = G_IMPLICIT_DEF
136 %3:_(s32) = G_CONSTANT i32 1
137 %4:_(<2 x s64>) = G_INSERT_VECTOR_ELT %2, %0(s64), %3(s32)
138 %5:_(<2 x s64>) = G_IMPLICIT_DEF
139 %6:_(<4 x s64>) = G_CONCAT_VECTORS %4(<2 x s64>), %5
140 RET_ReallyLR implicit %6