xref: /llvm-project/llvm/test/CodeGen/PowerPC/ctrloop-do-not-duplicate-mi.mir (revision 60442f0d442723a487528bdd8b48b24657a025e8)
1# RUN: llc -ppc-asm-full-reg-names -mtriple=powerpc64le-unknown-linux-gnu \
2# RUN:   -run-pass=early-tailduplication,ppc-ctrloops %s -o - -verify-machineinstrs 2>&1 | FileCheck %s
3
4--- |
5  target datalayout = "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512"
6  target triple = "powerpc64le-unknown-linux-gnu"
7
8  define dso_local void @test() local_unnamed_addr #0 {
9  test_entry:
10    %_val_domain_ = load i32, ptr undef, align 4
11    %_conv765 = sext i32 %_val_domain_ to i64
12    br i1 undef, label %_label_42, label %_loop_40_loopHeader_
13
14  _loop_40_loopHeader_:                             ; preds = %test_entry
15    %_val_flags_1020 = load i32, ptr undef, align 4
16    %0 = and i32 %_val_flags_1020, 1
17    %_cond_conv_1022.not = icmp eq i32 %0, 0
18    %1 = sub i64 1, %_conv765
19    %smax = call i64 @llvm.smax.i64(i64 %1, i64 1)
20    br label %_label_43
21
22  _label_43.loopexit:                               ; preds = %_loop_44_loopHeader_
23    %lsr.iv.next = add i64 %lsr.iv, -1
24    br label %_label_43
25
26  _label_43:                                        ; preds = %_label_43.loopexit, %_loop_40_loopHeader_
27    %lsr.iv = phi i64 [ %lsr.iv.next, %_label_43.loopexit ], [ undef, %_loop_40_loopHeader_ ]
28    call void @llvm.set.loop.iterations.i64(i64 %smax)
29    br label %_loop_44_do_
30
31  _loop_44_loopHeader_:                             ; preds = %_loop_44_do_
32    %2 = call i1 @llvm.loop.decrement.i64(i64 1)
33    br i1 %2, label %_loop_44_do_, label %_label_43.loopexit
34
35  _loop_44_do_:                                     ; preds = %_loop_44_loopHeader_, %_label_43
36    br i1 %_cond_conv_1022.not, label %_label_42.loopexit, label %_loop_44_loopHeader_
37
38  _label_42.loopexit:                               ; preds = %_loop_44_do_
39    %3 = trunc i64 %lsr.iv to i32
40    store i32 %3, ptr undef, align 4
41    unreachable
42
43  _label_42:                                        ; preds = %test_entry
44    unreachable
45  }
46
47  ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
48  declare i64 @llvm.smax.i64(i64, i64) #1
49
50  ; Function Attrs: nocallback noduplicate nofree nosync nounwind willreturn
51  declare void @llvm.set.loop.iterations.i64(i64) #2
52
53  ; Function Attrs: nocallback noduplicate nofree nosync nounwind willreturn
54  declare i1 @llvm.loop.decrement.i64(i64) #2
55
56  attributes #0 = { "unsafe-fp-math"="true" }
57  attributes #1 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
58  attributes #2 = { nocallback noduplicate nofree nosync nounwind willreturn }
59
60  !llvm.ident = !{!0}
61
62  !0 = !{!""}
63
64...
65---
66name:            test
67# CHECK: test
68alignment:       16
69exposesReturnsTwice: false
70legalized:       false
71regBankSelected: false
72selected:        false
73failedISel:      false
74tracksRegLiveness: true
75hasWinCFI:       false
76callsEHReturn:   false
77callsUnwindInit: false
78hasEHCatchret:   false
79hasEHScopes:     false
80hasEHFunclets:   false
81failsVerification: false
82tracksDebugUserValues: false
83registers:
84  - { id: 0, class: g8rc, preferred-register: '' }
85  - { id: 1, class: crbitrc, preferred-register: '' }
86  - { id: 2, class: g8rc, preferred-register: '' }
87  - { id: 3, class: g8rc, preferred-register: '' }
88  - { id: 4, class: g8rc_and_g8rc_nox0, preferred-register: '' }
89  - { id: 5, class: g8rc_and_g8rc_nox0, preferred-register: '' }
90  - { id: 6, class: crbitrc, preferred-register: '' }
91  - { id: 7, class: g8rc, preferred-register: '' }
92  - { id: 8, class: gprc, preferred-register: '' }
93  - { id: 9, class: g8rc_and_g8rc_nox0, preferred-register: '' }
94  - { id: 10, class: g8rc_and_g8rc_nox0, preferred-register: '' }
95  - { id: 11, class: crrc, preferred-register: '' }
96  - { id: 12, class: g8rc_and_g8rc_nox0, preferred-register: '' }
97  - { id: 13, class: crbitrc, preferred-register: '' }
98  - { id: 14, class: g8rc_and_g8rc_nox0, preferred-register: '' }
99  - { id: 15, class: gprc, preferred-register: '' }
100liveins:         []
101frameInfo:
102  isFrameAddressTaken: false
103  isReturnAddressTaken: false
104  hasStackMap:     false
105  hasPatchPoint:   false
106  stackSize:       0
107  offsetAdjustment: 0
108  maxAlignment:    1
109  adjustsStack:    false
110  hasCalls:        false
111  stackProtector:  ''
112  functionContext: ''
113  maxCallFrameSize: 4294967295
114  cvBytesOfCalleeSavedRegisters: 0
115  hasOpaqueSPAdjustment: false
116  hasVAStart:      false
117  hasMustTailInVarArgFunc: false
118  hasTailCall:     false
119  localFrameSize:  0
120  savePoint:       ''
121  restorePoint:    ''
122fixedStack:      []
123stack:           []
124callSites:       []
125debugValueSubstitutions: []
126constants:       []
127machineFunctionInfo: {}
128body:             |
129  bb.0.test_entry:
130    successors: %bb.7(0x40000000), %bb.1(0x40000000)
131
132    %5:g8rc_and_g8rc_nox0 = IMPLICIT_DEF
133    %0:g8rc = LWA 0, killed %5 :: (load (s32) from `ptr undef`)
134    %6:crbitrc = IMPLICIT_DEF
135    BC killed %6, %bb.7
136    B %bb.1
137
138  bb.1._loop_40_loopHeader_:
139    successors: %bb.3(0x80000000)
140
141    %9:g8rc_and_g8rc_nox0 = IMPLICIT_DEF
142    %8:gprc = LWZ 0, %9 :: (load (s32) from `ptr undef`)
143    %15:gprc = ANDI_rec %8, 1, implicit-def $cr0
144    %1:crbitrc = COPY $cr0eq
145    %10:g8rc_and_g8rc_nox0 = SUBFIC8 %0, 1, implicit-def dead $carry
146    %11:crrc = CMPDI %10, 1
147    %12:g8rc_and_g8rc_nox0 = LI8 1
148    %2:g8rc = ISEL8 %10, %12, %11.sub_gt
149    %7:g8rc = IMPLICIT_DEF
150    B %bb.3
151
152  bb.2._label_43.loopexit:
153    successors: %bb.3(0x80000000)
154
155    %3:g8rc = ADDI8 %4, -1
156
157  bb.3._label_43:
158    successors: %bb.5(0x80000000)
159
160    %4:g8rc_and_g8rc_nox0 = PHI %7, %bb.1, %3, %bb.2
161    MTCTR8loop %2, implicit-def dead $ctr8
162    B %bb.5
163
164  bb.4._loop_44_loopHeader_:
165    successors: %bb.5(0x7c000000), %bb.2(0x04000000)
166
167    %13:crbitrc = DecreaseCTR8loop 1, implicit-def dead $ctr8, implicit $ctr8
168    BCn killed %13, %bb.2
169    B %bb.5
170
171  bb.5._loop_44_do_:
172    successors: %bb.6(0x00000000), %bb.4(0x80000000)
173
174    BCn %1, %bb.4
175    B %bb.6
176
177  bb.6._label_42.loopexit:
178    successors:
179
180    %14:g8rc_and_g8rc_nox0 = IMPLICIT_DEF
181    STW8 %4, 0, killed %14 :: (store (s32) into `ptr undef`)
182
183  bb.7._label_42:
184
185...
186