1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -o - -mtriple=aarch64-unknown-unknown -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s | FileCheck %s --check-prefixes=CHECK
5 name: test_combine_trunc_xor_i64
8 ; CHECK-LABEL: name: test_combine_trunc_xor_i64
9 ; CHECK: %lhs:_(s64) = COPY $x0
10 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s64)
11 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
12 ; CHECK-NEXT: %small:_(s32) = G_XOR [[TRUNC]], [[C]]
13 ; CHECK-NEXT: $w0 = COPY %small(s32)
14 %lhs:_(s64) = COPY $x0
15 %rhs:_(s64) = G_CONSTANT i64 5
16 %res:_(s64) = G_XOR %lhs, %rhs
17 %small:_(s32) = G_TRUNC %res(s64)
18 $w0 = COPY %small(s32)
21 name: test_combine_trunc_add_i64
24 ; CHECK-LABEL: name: test_combine_trunc_add_i64
25 ; CHECK: %lhs:_(s64) = COPY $x0
26 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s64)
27 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
28 ; CHECK-NEXT: %small:_(s32) = G_ADD [[TRUNC]], [[C]]
29 ; CHECK-NEXT: $w0 = COPY %small(s32)
30 %lhs:_(s64) = COPY $x0
31 %rhs:_(s64) = G_CONSTANT i64 5
32 %res:_(s64) = G_ADD %lhs, %rhs
33 %small:_(s32) = G_TRUNC %res(s64)
34 $w0 = COPY %small(s32)
37 name: test_combine_trunc_mul_i64
40 ; CHECK-LABEL: name: test_combine_trunc_mul_i64
41 ; CHECK: %lhs:_(s64) = COPY $x0
42 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s64)
43 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
44 ; CHECK-NEXT: %small:_(s32) = G_MUL [[TRUNC]], [[C]]
45 ; CHECK-NEXT: $w0 = COPY %small(s32)
46 %lhs:_(s64) = COPY $x0
47 %rhs:_(s64) = G_CONSTANT i64 5
48 %res:_(s64) = G_MUL %lhs, %rhs
49 %small:_(s32) = G_TRUNC %res(s64)
50 $w0 = COPY %small(s32)
53 name: test_combine_trunc_and_i64
56 ; CHECK-LABEL: name: test_combine_trunc_and_i64
57 ; CHECK: %lhs:_(s64) = COPY $x0
58 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s64)
59 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
60 ; CHECK-NEXT: %small:_(s32) = G_AND [[TRUNC]], [[C]]
61 ; CHECK-NEXT: $w0 = COPY %small(s32)
62 %lhs:_(s64) = COPY $x0
63 %rhs:_(s64) = G_CONSTANT i64 5
64 %res:_(s64) = G_AND %lhs, %rhs
65 %small:_(s32) = G_TRUNC %res(s64)
66 $w0 = COPY %small(s32)
69 name: test_combine_trunc_or_i64
72 ; CHECK-LABEL: name: test_combine_trunc_or_i64
73 ; CHECK: %lhs:_(s64) = COPY $x0
74 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s64)
75 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 5
76 ; CHECK-NEXT: %small:_(s32) = G_OR [[TRUNC]], [[C]]
77 ; CHECK-NEXT: $w0 = COPY %small(s32)
78 %lhs:_(s64) = COPY $x0
79 %rhs:_(s64) = G_CONSTANT i64 5
80 %res:_(s64) = G_OR %lhs, %rhs
81 %small:_(s32) = G_TRUNC %res(s64)
82 $w0 = COPY %small(s32)
85 name: test_combine_trunc_sub_i128
88 ; CHECK-LABEL: name: test_combine_trunc_sub_i128
89 ; CHECK: %lhs:_(s128) = COPY $q0
90 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC %lhs(s128)
91 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -5
92 ; CHECK-NEXT: %small:_(s32) = G_ADD [[TRUNC]], [[C]]
93 ; CHECK-NEXT: $w0 = COPY %small(s32)
94 %lhs:_(s128) = COPY $q0
95 %rhs:_(s128) = G_CONSTANT i128 5
96 %res:_(s128) = G_SUB %lhs, %rhs
97 %small:_(s32) = G_TRUNC %res(s128)
98 $w0 = COPY %small(s32)
101 name: test_combine_trunc_sub_i128_multi_use
104 ; CHECK-LABEL: name: test_combine_trunc_sub_i128_multi_use
105 ; CHECK: %lhs:_(s128) = COPY $q0
106 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s128) = G_CONSTANT i128 -5
107 ; CHECK-NEXT: %res:_(s128) = G_ADD %lhs, [[C]]
108 ; CHECK-NEXT: %small:_(s32) = G_TRUNC %res(s128)
109 ; CHECK-NEXT: $q0 = COPY %res(s128)
110 ; CHECK-NEXT: $w0 = COPY %small(s32)
111 %lhs:_(s128) = COPY $q0
112 %rhs:_(s128) = G_CONSTANT i128 5
113 %res:_(s128) = G_SUB %lhs, %rhs
114 %small:_(s32) = G_TRUNC %res(s128)
115 $q0 = COPY %res(s128)
116 $w0 = COPY %small(s32)
119 name: test_combine_trunc_xor_vector_pattern_did_not_match
122 ; CHECK-LABEL: name: test_combine_trunc_xor_vector_pattern_did_not_match
123 ; CHECK: %arg1:_(s64) = COPY $x0
124 ; CHECK-NEXT: %arg2:_(s64) = COPY $x0
125 ; CHECK-NEXT: %lhs:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
126 ; CHECK-NEXT: %rhs:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
127 ; CHECK-NEXT: %res:_(<2 x s64>) = G_XOR %lhs, %rhs
128 ; CHECK-NEXT: %small:_(<2 x s16>) = G_TRUNC %res(<2 x s64>)
129 ; CHECK-NEXT: $w0 = COPY %small(<2 x s16>)
130 %arg1:_(s64) = COPY $x0
131 %arg2:_(s64) = COPY $x0
132 %lhs:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
133 %rhs:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
134 %res:_(<2 x s64>) = G_XOR %lhs, %rhs
135 %small:_(<2 x s16>) = G_TRUNC %res(<2 x s64>)
136 $w0 = COPY %small(<2 x s16>)