1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64_be-- < %s | FileCheck %s --check-prefix=BE
3 ; RUN: llc -mtriple=aarch64-- < %s | FileCheck %s --check-prefix=LE
5 define i32 @trunc_i64_to_i32_le(i64 %x) {
6 ; BE-LABEL: trunc_i64_to_i32_le:
9 ; BE-NEXT: rev64 v0.4s, v0.4s
10 ; BE-NEXT: fmov w0, s0
13 ; LE-LABEL: trunc_i64_to_i32_le:
15 ; LE-NEXT: // kill: def $w0 killed $w0 killed $x0
17 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
18 %bc = bitcast <2 x i64> %ins to <4 x i32>
19 %ext = extractelement <4 x i32> %bc, i32 0
23 define i32 @trunc_i64_to_i32_be(i64 %x) {
24 ; BE-LABEL: trunc_i64_to_i32_be:
26 ; BE-NEXT: // kill: def $w0 killed $w0 killed $x0
29 ; LE-LABEL: trunc_i64_to_i32_be:
31 ; LE-NEXT: fmov d0, x0
32 ; LE-NEXT: mov w0, v0.s[1]
34 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
35 %bc = bitcast <2 x i64> %ins to <4 x i32>
36 %ext = extractelement <4 x i32> %bc, i32 1
40 define i16 @trunc_i64_to_i16_le(i64 %x) {
41 ; BE-LABEL: trunc_i64_to_i16_le:
43 ; BE-NEXT: fmov d0, x0
44 ; BE-NEXT: rev64 v0.8h, v0.8h
45 ; BE-NEXT: umov w0, v0.h[0]
48 ; LE-LABEL: trunc_i64_to_i16_le:
50 ; LE-NEXT: // kill: def $w0 killed $w0 killed $x0
52 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
53 %bc = bitcast <2 x i64> %ins to <8 x i16>
54 %ext = extractelement <8 x i16> %bc, i32 0
58 define i16 @trunc_i64_to_i16_be(i64 %x) {
59 ; BE-LABEL: trunc_i64_to_i16_be:
61 ; BE-NEXT: // kill: def $w0 killed $w0 killed $x0
64 ; LE-LABEL: trunc_i64_to_i16_be:
66 ; LE-NEXT: fmov d0, x0
67 ; LE-NEXT: umov w0, v0.h[3]
69 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
70 %bc = bitcast <2 x i64> %ins to <8 x i16>
71 %ext = extractelement <8 x i16> %bc, i32 3
75 define i8 @trunc_i32_to_i8_le(i32 %x) {
76 ; BE-LABEL: trunc_i32_to_i8_le:
78 ; BE-NEXT: fmov s0, w0
79 ; BE-NEXT: rev32 v0.16b, v0.16b
80 ; BE-NEXT: umov w0, v0.b[0]
83 ; LE-LABEL: trunc_i32_to_i8_le:
86 %ins = insertelement <4 x i32> undef, i32 %x, i32 0
87 %bc = bitcast <4 x i32> %ins to <16 x i8>
88 %ext = extractelement <16 x i8> %bc, i32 0
92 define i8 @trunc_i32_to_i8_be(i32 %x) {
93 ; BE-LABEL: trunc_i32_to_i8_be:
97 ; LE-LABEL: trunc_i32_to_i8_be:
99 ; LE-NEXT: fmov s0, w0
100 ; LE-NEXT: umov w0, v0.b[3]
102 %ins = insertelement <4 x i32> undef, i32 %x, i32 0
103 %bc = bitcast <4 x i32> %ins to <16 x i8>
104 %ext = extractelement <16 x i8> %bc, i32 3
108 ; Weird type (non-power-of-2 vector) is ok.
110 define i8 @trunc_i64_to_i8_be(i64 %x) {
111 ; BE-LABEL: trunc_i64_to_i8_be:
113 ; BE-NEXT: // kill: def $w0 killed $w0 killed $x0
116 ; LE-LABEL: trunc_i64_to_i8_be:
118 ; LE-NEXT: fmov d0, x0
119 ; LE-NEXT: umov w0, v0.b[7]
121 %ins = insertelement <3 x i64> undef, i64 %x, i32 0
122 %bc = bitcast <3 x i64> %ins to <24 x i8>
123 %ext = extractelement <24 x i8> %bc, i32 7