1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64 < %s | FileCheck %s
4 ; This test is reduced fom https://github.com/android/ndk/issues/1207 for an
5 ; issue with the following DAGCobmine operation:
6 ; truncate(build_vector(x,y)) -> build_vector(truncate(x),truncate(y))
7 ; The combine should avoid creating illegal types if types have already been
10 define void @no_combine(i32 %p) local_unnamed_addr {
11 ; CHECK-LABEL: no_combine:
13 ; CHECK-NEXT: movi v0.4h, #4
14 ; CHECK-NEXT: dup v1.4h, w0
15 ; CHECK-NEXT: mov v1.d[1], v0.d[0]
16 ; CHECK-NEXT: uzp1 v0.16b, v1.16b, v1.16b
17 ; CHECK-NEXT: str q0, [x8]
20 ; The two shufflevector operations are needed to force the DAGCombine to happen
21 ; after type legalization and before operation legalization. Removing either
22 ; makes the combine to happen before type legalization and the issue no longer
24 %1 = insertelement <16 x i32> undef, i32 %p, i32 0
25 %2 = shufflevector <16 x i32> %1, <16 x i32> undef, <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 undef, i32 undef, i32 undef, i32 undef, i32 0, i32 0, i32 0, i32 0, i32 undef, i32 undef, i32 undef, i32 undef>
26 %3 = shufflevector <16 x i32> %2, <16 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 4, i32 4, i32 4, i32 4, i32 undef, i32 undef, i32 undef, i32 undef, i32 4, i32 4, i32 4, i32 4>, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 20, i32 21, i32 22, i32 23, i32 8, i32 9, i32 10, i32 11, i32 28, i32 29, i32 30, i32 31>
27 %4 = trunc <16 x i32> %3 to <16 x i8>
28 %5 = bitcast i8* undef to <16 x i8>*
29 store <16 x i8> %4, <16 x i8>* %5, align 1
33 ; Test case to ensure that the combine is done before type legalization.
34 define void @do_combine(i32 %p) local_unnamed_addr {
35 ; CHECK-LABEL: do_combine:
37 ; CHECK-NEXT: dup v0.16b, w0
38 ; CHECK-NEXT: str q0, [x8]
40 %1 = insertelement <16 x i32> undef, i32 %p, i32 0
41 %2 = shufflevector <16 x i32> %1, <16 x i32> undef, <16 x i32> <i32 0, i32 0, i32 0, i32 0, i32 undef, i32 undef, i32 undef, i32 undef, i32 0, i32 0, i32 0, i32 0, i32 undef, i32 undef, i32 undef, i32 undef>
42 %3 = trunc <16 x i32> %2 to <16 x i8>
43 %4 = bitcast i8* undef to <16 x i8>*
44 store <16 x i8> %3, <16 x i8>* %4, align 1