1# RUN: llc -O0 -mtriple aarch64-apple-ios %s -global-isel -start-after regbankselect \
2# RUN:    -stop-before instruction-select -o - | FileCheck --check-prefix=CHECK --check-prefix=OPTNONE %s
3# RUN: llc -mtriple aarch64-apple-ios %s -global-isel -start-after regbankselect \
4# RUN:   -stop-before instruction-select -o - | FileCheck --check-prefix=CHECK --check-prefix=OPT %s
5#
6# Check that we are only running the localizer at O0 and that it runs
7# between the regbankselect pass and the instruction-select.
8# Moreover, check that it does what we expect.
9--- |
10  target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
11  target triple = "aarch64-apple-ios"
12
13  define float @foo(float %arg, i1 %cond) {
14    br i1 %cond, label %true, label %false
15
16  true:                                             ; preds = %0
17    br label %end
18
19  false:                                            ; preds = %0
20    br label %end
21
22  end:                                              ; preds = %false, %true
23    %val = phi float [ 1.000000e+00, %true ], [ 2.000000e+00, %false ]
24    %res = fadd float %arg, %val
25    ret float %res
26  }
27
28...
29---
30# CHECK-LABEL: name: foo
31name:            foo
32alignment:       2
33legalized:       true
34regBankSelected: true
35tracksRegLiveness: true
36registers:
37# CHECK: registers:
38# CHECK-NEXT: - { id: 0, class: fpr, preferred-register: '' }
39# CHECK-NEXT: - { id: 1, class: gpr, preferred-register: '' }
40# CHECK-NEXT: - { id: 2, class: fpr, preferred-register: '' }
41# CHECK-NEXT: - { id: 3, class: fpr, preferred-register: '' }
42# CHECK-NEXT: - { id: 4, class: fpr, preferred-register: '' }
43# CHECK-NEXT: - { id: 5, class: fpr, preferred-register: '' }
44# CHECK-NEXT: - { id: 6, class: gpr, preferred-register: '' }
45# The localizer will create two new values to materialize the constants.
46# OPTNONE-NEXT:  - { id: 7, class: fpr, preferred-register: '' }
47# OPTNONE-NEXT:  - { id: 8, class: fpr, preferred-register: '' }
48  - { id: 0, class: fpr }
49  - { id: 1, class: gpr }
50  - { id: 2, class: fpr }
51  - { id: 3, class: fpr }
52  - { id: 4, class: fpr }
53  - { id: 5, class: fpr }
54  - { id: 6, class: gpr }
55
56# First block remains untouched
57# CHECK: body
58# CHECK:   %4:fpr(s32) = G_FCONSTANT float 1.000000e+00
59# CHECK:   %5:fpr(s32) = G_FCONSTANT float 2.000000e+00
60
61# Second block will get the constant 1.0 when the localizer is enabled.
62# CHECK: bb.1.{{[a-zA-Z0-9]+}}:
63# OPT-NOT: G_FCONSTANT
64# OPTNONE: [[FONE:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 1.000000e+00
65# CHECK: G_BR %bb.3
66
67# Thrid block will get the constant 2.0 when the localizer is enabled.
68# CHECK: bb.2.{{[a-zA-Z0-9]+}}:
69# OPT-NOT: G_FCONSTANT
70# OPTNONE: [[FTWO:%[0-9]+]]:fpr(s32) = G_FCONSTANT float 2.000000e+00
71
72# CHECK: bb.3.end
73# OPTNONE: %2:fpr(s32) = PHI [[FONE]](s32), %bb.1, [[FTWO]](s32), %bb.2
74# OPT: %2:fpr(s32) = PHI %4(s32), %bb.1, %5(s32), %bb.2
75# CHECK-NEXT: G_FADD %0, %2
76body:             |
77  bb.0 (%ir-block.0):
78    liveins: $s0, $w0
79
80    %0(s32) = COPY $s0
81    %6(s32) = COPY $w0
82    %1(s1) = G_TRUNC %6
83    %4(s32) = G_FCONSTANT float 1.000000e+00
84    %5(s32) = G_FCONSTANT float 2.000000e+00
85    G_BRCOND %1(s1), %bb.1
86    G_BR %bb.2
87
88  bb.1.true:
89    G_BR %bb.3
90
91  bb.2.false:
92
93  bb.3.end:
94    %2(s32) = PHI %4(s32), %bb.1, %5(s32), %bb.2
95    %3(s32) = G_FADD %0, %2
96    $s0 = COPY %3(s32)
97    RET_ReallyLR implicit $s0
98
99...
100