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:
8 ; BE-NEXT: lsr x0, x0, #32
9 ; BE-NEXT: // kill: def $w0 killed $w0 killed $x0
12 ; LE-LABEL: trunc_i64_to_i32_le:
14 ; LE-NEXT: // kill: def $w0 killed $w0 killed $x0
16 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
17 %bc = bitcast <2 x i64> %ins to <4 x i32>
18 %ext = extractelement <4 x i32> %bc, i32 0
22 define i32 @trunc_i64_to_i32_be(i64 %x) {
23 ; BE-LABEL: trunc_i64_to_i32_be:
25 ; BE-NEXT: // kill: def $w0 killed $w0 killed $x0
28 ; LE-LABEL: trunc_i64_to_i32_be:
30 ; LE-NEXT: lsr x0, x0, #32
31 ; LE-NEXT: // kill: def $w0 killed $w0 killed $x0
33 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
34 %bc = bitcast <2 x i64> %ins to <4 x i32>
35 %ext = extractelement <4 x i32> %bc, i32 1
39 define i16 @trunc_i64_to_i16_le(i64 %x) {
40 ; BE-LABEL: trunc_i64_to_i16_le:
42 ; BE-NEXT: lsr x0, x0, #48
43 ; BE-NEXT: // kill: def $w0 killed $w0 killed $x0
46 ; LE-LABEL: trunc_i64_to_i16_le:
48 ; LE-NEXT: // kill: def $w0 killed $w0 killed $x0
50 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
51 %bc = bitcast <2 x i64> %ins to <8 x i16>
52 %ext = extractelement <8 x i16> %bc, i32 0
56 define i16 @trunc_i64_to_i16_be(i64 %x) {
57 ; BE-LABEL: trunc_i64_to_i16_be:
59 ; BE-NEXT: // kill: def $w0 killed $w0 killed $x0
62 ; LE-LABEL: trunc_i64_to_i16_be:
64 ; LE-NEXT: lsr x0, x0, #48
65 ; LE-NEXT: // kill: def $w0 killed $w0 killed $x0
67 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
68 %bc = bitcast <2 x i64> %ins to <8 x i16>
69 %ext = extractelement <8 x i16> %bc, i32 3
73 define i8 @trunc_i32_to_i8_le(i32 %x) {
74 ; BE-LABEL: trunc_i32_to_i8_le:
76 ; BE-NEXT: lsr w0, w0, #24
79 ; LE-LABEL: trunc_i32_to_i8_le:
82 %ins = insertelement <4 x i32> undef, i32 %x, i32 0
83 %bc = bitcast <4 x i32> %ins to <16 x i8>
84 %ext = extractelement <16 x i8> %bc, i32 0
88 define i8 @trunc_i32_to_i8_be(i32 %x) {
89 ; BE-LABEL: trunc_i32_to_i8_be:
93 ; LE-LABEL: trunc_i32_to_i8_be:
95 ; LE-NEXT: lsr w0, w0, #24
97 %ins = insertelement <4 x i32> undef, i32 %x, i32 0
98 %bc = bitcast <4 x i32> %ins to <16 x i8>
99 %ext = extractelement <16 x i8> %bc, i32 3
103 ; Weird type (non-power-of-2 vector) is ok.
105 define i8 @trunc_i64_to_i8_be(i64 %x) {
106 ; BE-LABEL: trunc_i64_to_i8_be:
108 ; BE-NEXT: // kill: def $w0 killed $w0 killed $x0
111 ; LE-LABEL: trunc_i64_to_i8_be:
113 ; LE-NEXT: lsr x0, x0, #56
114 ; LE-NEXT: // kill: def $w0 killed $w0 killed $x0
116 %ins = insertelement <3 x i64> undef, i64 %x, i32 0
117 %bc = bitcast <3 x i64> %ins to <24 x i8>
118 %ext = extractelement <24 x i8> %bc, i32 7