1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-unknown \
3 ; RUN: -ppc-asm-full-reg-names -verify-machineinstrs -O2 < %s | FileCheck %s \
4 ; RUN: --check-prefix=CHECK-P9
6 define i32 @t(i32 %n, i32 %delta, i32 %a) {
8 ; CHECK-P9: # %bb.0: # %entry
9 ; CHECK-P9-NEXT: lis r7, 0
10 ; CHECK-P9-NEXT: li r6, 0
11 ; CHECK-P9-NEXT: li r8, 0
12 ; CHECK-P9-NEXT: li r9, 0
13 ; CHECK-P9-NEXT: ori r7, r7, 65535
14 ; CHECK-P9-NEXT: .p2align 5
15 ; CHECK-P9-NEXT: .LBB0_1: # %header
17 ; CHECK-P9-NEXT: addi r9, r9, 1
18 ; CHECK-P9-NEXT: cmpw r9, r3
19 ; CHECK-P9-NEXT: blt cr0, .LBB0_4
20 ; CHECK-P9-NEXT: # %bb.2: # %cont
22 ; CHECK-P9-NEXT: add r8, r8, r4
23 ; CHECK-P9-NEXT: cmpw r8, r7
24 ; CHECK-P9-NEXT: bgt cr0, .LBB0_1
25 ; CHECK-P9-NEXT: # %bb.3: # %cont.1
26 ; CHECK-P9-NEXT: addi r6, r5, 1024
27 ; CHECK-P9-NEXT: .LBB0_4: # %return
28 ; CHECK-P9-NEXT: addi r3, r5, 1024
29 ; CHECK-P9-NEXT: mullw r3, r6, r3
35 %sum = phi i32 [ 0, %entry ], [ %sum.1, %cont ]
36 %i = phi i32 [ 0, %entry ], [ %i.1, %cont ]
37 %i.1 = add nsw i32 %i, 1
38 %lt = icmp slt i32 %i.1, %n
39 br i1 %lt, label %return, label %cont
42 %sum.1 = add nsw i32 %sum, %delta
43 %lt.1 = icmp slt i32 %sum.1, 65536
44 br i1 %lt.1, label %cont.1, label %header
47 %delta.1 = add nsw i32 %a, 1024
51 %delta.2 = phi i32 [ %delta.1, %cont.1 ], [ 0, %header ]
52 %delta.3 = add nsw i32 %a, 1024
53 %ret = mul i32 %delta.2, %delta.3
57 define dso_local signext i32 @foo(i32 signext %x, i32 signext %y) nounwind {
58 ; CHECK-P9-LABEL: foo:
59 ; CHECK-P9: # %bb.0: # %entry
60 ; CHECK-P9-NEXT: mflr r0
61 ; CHECK-P9-NEXT: std r27, -40(r1) # 8-byte Folded Spill
62 ; CHECK-P9-NEXT: std r28, -32(r1) # 8-byte Folded Spill
63 ; CHECK-P9-NEXT: std r29, -24(r1) # 8-byte Folded Spill
64 ; CHECK-P9-NEXT: std r30, -16(r1) # 8-byte Folded Spill
65 ; CHECK-P9-NEXT: std r0, 16(r1)
66 ; CHECK-P9-NEXT: stdu r1, -80(r1)
67 ; CHECK-P9-NEXT: mr r30, r4
68 ; CHECK-P9-NEXT: mr r29, r3
69 ; CHECK-P9-NEXT: lis r3, 21845
70 ; CHECK-P9-NEXT: add r28, r30, r29
71 ; CHECK-P9-NEXT: ori r27, r3, 21846
72 ; CHECK-P9-NEXT: b .LBB1_4
73 ; CHECK-P9-NEXT: .p2align 4
74 ; CHECK-P9-NEXT: .LBB1_1: # %sw.bb3
76 ; CHECK-P9-NEXT: mulli r3, r30, 23
77 ; CHECK-P9-NEXT: .LBB1_2: # %sw.epilog
79 ; CHECK-P9-NEXT: add r28, r3, r28
80 ; CHECK-P9-NEXT: .LBB1_3: # %sw.epilog
82 ; CHECK-P9-NEXT: cmpwi r28, 1025
83 ; CHECK-P9-NEXT: bge cr0, .LBB1_7
84 ; CHECK-P9-NEXT: .LBB1_4: # %while.cond
86 ; CHECK-P9-NEXT: extsw r3, r29
87 ; CHECK-P9-NEXT: bl bar
89 ; CHECK-P9-NEXT: mr r29, r3
90 ; CHECK-P9-NEXT: extsw r3, r30
91 ; CHECK-P9-NEXT: bl bar
93 ; CHECK-P9-NEXT: mr r30, r3
94 ; CHECK-P9-NEXT: extsw r3, r28
95 ; CHECK-P9-NEXT: mulld r4, r3, r27
96 ; CHECK-P9-NEXT: rldicl r5, r4, 1, 63
97 ; CHECK-P9-NEXT: rldicl r4, r4, 32, 32
98 ; CHECK-P9-NEXT: add r4, r4, r5
99 ; CHECK-P9-NEXT: slwi r5, r4, 1
100 ; CHECK-P9-NEXT: add r4, r4, r5
101 ; CHECK-P9-NEXT: subf r3, r4, r3
102 ; CHECK-P9-NEXT: cmplwi r3, 1
103 ; CHECK-P9-NEXT: beq cr0, .LBB1_1
104 ; CHECK-P9-NEXT: # %bb.5: # %while.cond
106 ; CHECK-P9-NEXT: cmplwi r3, 0
107 ; CHECK-P9-NEXT: bne cr0, .LBB1_3
108 ; CHECK-P9-NEXT: # %bb.6: # %sw.bb
110 ; CHECK-P9-NEXT: mulli r3, r29, 13
111 ; CHECK-P9-NEXT: b .LBB1_2
112 ; CHECK-P9-NEXT: .LBB1_7: # %while.end
113 ; CHECK-P9-NEXT: lis r3, -13108
114 ; CHECK-P9-NEXT: ori r3, r3, 52429
115 ; CHECK-P9-NEXT: mullw r3, r28, r3
116 ; CHECK-P9-NEXT: lis r4, 13107
117 ; CHECK-P9-NEXT: ori r4, r4, 13108
118 ; CHECK-P9-NEXT: cmplw r3, r4
119 ; CHECK-P9-NEXT: blt cr0, .LBB1_9
120 ; CHECK-P9-NEXT: # %bb.8: # %if.then8
121 ; CHECK-P9-NEXT: mulli r3, r29, 13
122 ; CHECK-P9-NEXT: mulli r5, r30, 23
123 ; CHECK-P9-NEXT: extsw r4, r28
124 ; CHECK-P9-NEXT: extsw r3, r3
125 ; CHECK-P9-NEXT: extsw r5, r5
126 ; CHECK-P9-NEXT: sub r3, r4, r3
127 ; CHECK-P9-NEXT: sub r4, r5, r4
128 ; CHECK-P9-NEXT: rldicl r3, r3, 1, 63
129 ; CHECK-P9-NEXT: rldicl r4, r4, 1, 63
130 ; CHECK-P9-NEXT: or r3, r3, r4
131 ; CHECK-P9-NEXT: b .LBB1_10
132 ; CHECK-P9-NEXT: .LBB1_9: # %cleanup20
133 ; CHECK-P9-NEXT: li r3, 0
134 ; CHECK-P9-NEXT: .LBB1_10: # %cleanup20
135 ; CHECK-P9-NEXT: addi r1, r1, 80
136 ; CHECK-P9-NEXT: ld r0, 16(r1)
137 ; CHECK-P9-NEXT: mtlr r0
138 ; CHECK-P9-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
139 ; CHECK-P9-NEXT: ld r29, -24(r1) # 8-byte Folded Reload
140 ; CHECK-P9-NEXT: ld r28, -32(r1) # 8-byte Folded Reload
141 ; CHECK-P9-NEXT: ld r27, -40(r1) # 8-byte Folded Reload
144 %add = add nsw i32 %y, %x
147 while.cond: ; preds = %sw.epilog, %entry
148 %sum.0 = phi i32 [ %add, %entry ], [ %sum.1, %sw.epilog ]
149 %y.addr.0 = phi i32 [ %y, %entry ], [ %call1, %sw.epilog ]
150 %x.addr.0 = phi i32 [ %x, %entry ], [ %call, %sw.epilog ]
151 %call = tail call signext i32 @bar(i32 signext %x.addr.0) #2
152 %call1 = tail call signext i32 @bar(i32 signext %y.addr.0) #2
153 %rem = srem i32 %sum.0, 3
154 switch i32 %rem, label %sw.epilog [
159 sw.bb: ; preds = %while.cond
160 %mul = mul nsw i32 %call, 13
161 %add2 = add nsw i32 %mul, %sum.0
164 sw.bb3: ; preds = %while.cond
165 %mul4 = mul nsw i32 %call1, 23
166 %add5 = add nsw i32 %mul4, %sum.0
169 sw.epilog: ; preds = %while.cond, %sw.bb3, %sw.bb
170 %sum.1 = phi i32 [ %sum.0, %while.cond ], [ %add5, %sw.bb3 ], [ %add2, %sw.bb ]
171 %cmp = icmp slt i32 %sum.1, 1025
172 br i1 %cmp, label %while.cond, label %while.end
174 while.end: ; preds = %sw.epilog
175 %rem739 = urem i32 %sum.1, 5
176 %tobool = icmp eq i32 %rem739, 0
177 br i1 %tobool, label %cleanup20, label %if.then8
179 if.then8: ; preds = %while.end
180 %mul9 = mul nsw i32 %call, 13
181 %cmp11 = icmp slt i32 %sum.1, %mul9
182 %mul10 = mul nsw i32 %call1, 23
183 %cmp12 = icmp sgt i32 %sum.1, %mul10
184 %or.cond = or i1 %cmp11, %cmp12
185 %spec.select = zext i1 %or.cond to i32
188 cleanup20: ; preds = %while.end
192 declare signext i32 @bar(i32 signext) local_unnamed_addr #1