1 ; RUN: not llc -O0 -global-isel -global-isel-abort=1 -verify-machineinstrs %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
2 ; RUN: llc -O0 -global-isel -global-isel-abort=0 -verify-machineinstrs %s -o - 2>&1 | FileCheck %s --check-prefix=FALLBACK
3 ; RUN: llc -O0 -global-isel -global-isel-abort=2 -pass-remarks-missed='gisel*' -verify-machineinstrs %s -o %t.out 2> %t.err
4 ; RUN: FileCheck %s --check-prefix=FALLBACK-WITH-REPORT-OUT < %t.out
5 ; RUN: FileCheck %s --check-prefix=FALLBACK-WITH-REPORT-ERR < %t.err
6 ; RUN: not llc -global-isel -mtriple aarch64_be %s -o - 2>&1 | FileCheck %s --check-prefix=BIG-ENDIAN
7 ; This file checks that the fallback path to selection dag works.
8 ; The test is fragile in the sense that it must be updated to expose
9 ; something that fails with global-isel.
10 ; When we cannot produce a test case anymore, that means we can remove
13 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
14 target triple = "aarch64--"
16 ; BIG-ENDIAN: unable to translate in big endian mode
18 ; We use __fixunstfti as the common denominator for __fixunstfti on Linux and
19 ; ___fixunstfti on iOS
20 ; ERROR: unable to lower arguments: i128 (i128)* (in function: ABIi128)
22 ; FALLBACK-NEXT: bl __fixunstfti
24 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to lower arguments: i128 (i128)* (in function: ABIi128)
25 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for ABIi128
26 ; FALLBACK-WITH-REPORT-OUT-LABEL: ABIi128:
27 ; FALLBACK-WITH-REPORT-OUT: ldr q0,
28 ; FALLBACK-WITH-REPORT-OUT-NEXT: bl __fixunstfti
29 define i128 @ABIi128(i128 %arg1) {
30 %farg1 = bitcast i128 %arg1 to fp128
31 %res = fptoui fp128 %farg1 to i128
35 ; The key problem here is that we may fail to create an MBB referenced by a
36 ; PHI. If so, we cannot complete the G_PHI and mustn't try or bad things
38 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: cannot select: G_STORE %6:gpr(s32), %2:gpr(p0) :: (store seq_cst 4 into %ir.addr) (in function: pending_phis)
39 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for pending_phis
40 ; FALLBACK-WITH-REPORT-OUT-LABEL: pending_phis:
41 define i32 @pending_phis(i1 %tst, i32 %val, i32* %addr) {
42 br i1 %tst, label %true, label %false
45 %res = phi i32 [%val, %true], [42, %false]
49 store atomic i32 42, i32* %addr seq_cst, align 4
57 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to legalize instruction: G_STORE %1:_(<7 x s32>), %0:_(p0) :: (store 28 into %ir.addr, align 32) (in function: odd_vector)
58 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for odd_vector
59 ; FALLBACK-WITH-REPORT-OUT-LABEL: odd_vector:
60 define void @odd_vector(<7 x i32>* %addr) {
61 %vec = load <7 x i32>, <7 x i32>* %addr
62 store <7 x i32> %vec, <7 x i32>* %addr
66 ; AArch64 was asserting instead of returning an invalid mapping for unknown
68 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to translate instruction: ret: ' ret i128 undef' (in function: sequence_sizes)
69 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for sequence_sizes
70 ; FALLBACK-WITH-REPORT-LABEL: sequence_sizes:
71 define i128 @sequence_sizes([8 x i8] %in) {
75 ; Just to make sure we don't accidentally emit a normal load/store.
76 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: cannot select: %2:gpr(s64) = G_LOAD %0:gpr(p0) :: (load seq_cst 8 from %ir.addr) (in function: atomic_ops)
77 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for atomic_ops
78 ; FALLBACK-WITH-REPORT-LABEL: atomic_ops:
79 define i64 @atomic_ops(i64* %addr) {
80 store atomic i64 0, i64* %addr unordered, align 8
81 %res = load atomic i64, i64* %addr seq_cst, align 8
85 ; Make sure we don't mess up metadata arguments.
86 declare void @llvm.write_register.i64(metadata, i64)
88 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to translate instruction: call: ' call void @llvm.write_register.i64(metadata !0, i64 0)' (in function: test_write_register_intrin)
89 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for test_write_register_intrin
90 ; FALLBACK-WITH-REPORT-LABEL: test_write_register_intrin:
91 define void @test_write_register_intrin() {
92 call void @llvm.write_register.i64(metadata !{!"sp"}, i64 0)
96 @_ZTIi = external global i8*
97 declare i32 @__gxx_personality_v0(...)
99 ; Check that we fallback on invoke translation failures.
100 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to translate instruction: invoke: ' invoke void %callee(i128 0)
101 ; FALLBACK-WITH-REPORT-NEXT: to label %continue unwind label %broken' (in function: invoke_weird_type)
102 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for invoke_weird_type
103 ; FALLBACK-WITH-REPORT-OUT-LABEL: invoke_weird_type:
104 define void @invoke_weird_type(void(i128)* %callee) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
105 invoke void %callee(i128 0)
106 to label %continue unwind label %broken
109 landingpad { i8*, i32 } catch i8* bitcast(i8** @_ZTIi to i8*)
116 ; Check that we fallback on invoke translation failures.
117 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to legalize instruction: %0:_(s128) = G_FCONSTANT fp128 0xL00000000000000004000000000000000
118 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for test_quad_dump
119 ; FALLBACK-WITH-REPORT-OUT-LABEL: test_quad_dump:
120 define fp128 @test_quad_dump() {
121 ret fp128 0xL00000000000000004000000000000000
124 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to legalize instruction: %2:_(p0) = G_EXTRACT_VECTOR_ELT %0:_(<2 x p0>), %3:_(s64) (in function: vector_of_pointers_extractelement)
125 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for vector_of_pointers_extractelement
126 ; FALLBACK-WITH-REPORT-OUT-LABEL: vector_of_pointers_extractelement:
127 @var = global <2 x i16*> zeroinitializer
128 define void @vector_of_pointers_extractelement() {
132 %dummy = extractelement <2 x i16*> %vec, i32 0
133 store i16* %dummy, i16** undef
137 %vec = load <2 x i16*>, <2 x i16*>* undef
141 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to legalize instruction: %2:_(<2 x p0>) = G_INSERT_VECTOR_ELT %0:_, %3:_(p0), %5:_(s32) (in function: vector_of_pointers_insertelement)
142 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for vector_of_pointers_insertelement
143 ; FALLBACK-WITH-REPORT-OUT-LABEL: vector_of_pointers_insertelement:
144 define void @vector_of_pointers_insertelement() {
148 %dummy = insertelement <2 x i16*> %vec, i16* null, i32 0
149 store <2 x i16*> %dummy, <2 x i16*>* undef
153 %vec = load <2 x i16*>, <2 x i16*>* undef
157 ; FALLBACK-WITH-REPORT-ERR remark: <unknown>:0:0: unable to legalize instruction: G_STORE %3, %4 :: (store 12 into `i96* undef`, align 16) (in function: nonpow2_add_narrowing)
158 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for nonpow2_add_narrowing
159 ; FALLBACK-WITH-REPORT-OUT-LABEL: nonpow2_add_narrowing:
160 define void @nonpow2_add_narrowing() {
161 %a = add i128 undef, undef
162 %b = trunc i128 %a to i96
163 %dummy = add i96 %b, %b
164 store i96 %dummy, i96* undef
168 ; FALLBACK-WITH-REPORT-ERR remark: <unknown>:0:0: unable to legalize instruction: G_STORE %3, %4 :: (store 12 into `i96* undef`, align 16) (in function: nonpow2_add_narrowing)
169 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for nonpow2_or_narrowing
170 ; FALLBACK-WITH-REPORT-OUT-LABEL: nonpow2_or_narrowing:
171 define void @nonpow2_or_narrowing() {
172 %a = add i128 undef, undef
173 %b = trunc i128 %a to i96
174 %dummy = or i96 %b, %b
175 store i96 %dummy, i96* undef
179 ; FALLBACK-WITH-REPORT-ERR remark: <unknown>:0:0: unable to legalize instruction: G_STORE %0, %1 :: (store 12 into `i96* undef`, align 16) (in function: nonpow2_load_narrowing)
180 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for nonpow2_load_narrowing
181 ; FALLBACK-WITH-REPORT-OUT-LABEL: nonpow2_load_narrowing:
182 define void @nonpow2_load_narrowing() {
183 %dummy = load i96, i96* undef
184 store i96 %dummy, i96* undef
188 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: cannot select: %5:fpr32(s32) = G_EXTRACT %{{[0-9]+}}:fpr(s128), 64 (in function: nonpow2_store_narrowing)
189 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for nonpow2_store_narrowing
190 ; FALLBACK-WITH-REPORT-OUT-LABEL: nonpow2_store_narrowing:
191 define void @nonpow2_store_narrowing(i96* %c) {
192 %a = add i128 undef, undef
193 %b = trunc i128 %a to i96
194 store i96 %b, i96* %c
198 ; Currently can't handle vector lengths that aren't an exact multiple of
199 ; natively supported vector lengths. Test that the fall-back works for those.
200 ; FALLBACK-WITH-REPORT-ERR-G_IMPLICIT_DEF-LEGALIZABLE: (FIXME: this is what is expected once we can legalize non-pow-of-2 G_IMPLICIT_DEF) remark: <unknown>:0:0: unable to legalize instruction: %1:_(<7 x s64>) = G_ADD %0, %0 (in function: nonpow2_vector_add_fewerelements
201 ; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to legalize instruction: %2:_(s64) = G_EXTRACT_VECTOR_ELT %1:_(<7 x s64>), %3:_(s64) (in function: nonpow2_vector_add_fewerelements)
202 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for nonpow2_vector_add_fewerelements
203 ; FALLBACK-WITH-REPORT-OUT-LABEL: nonpow2_vector_add_fewerelements:
204 define void @nonpow2_vector_add_fewerelements() {
205 %dummy = add <7 x i64> undef, undef
206 %ex = extractelement <7 x i64> %dummy, i64 0
207 store i64 %ex, i64* undef