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: stdu r1, -80(r1)
66 ; CHECK-P9-NEXT: mr r30, r4
67 ; CHECK-P9-NEXT: mr r29, r3
68 ; CHECK-P9-NEXT: lis r3, 21845
69 ; CHECK-P9-NEXT: std r0, 96(r1)
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: mr r3, r29
87 ; CHECK-P9-NEXT: bl bar
89 ; CHECK-P9-NEXT: mr r29, r3
90 ; CHECK-P9-NEXT: mr r3, r30
91 ; CHECK-P9-NEXT: bl bar
93 ; CHECK-P9-NEXT: mr r30, r3
94 ; CHECK-P9-NEXT: mulhw r3, r28, r27
95 ; CHECK-P9-NEXT: srwi r4, r3, 31
96 ; CHECK-P9-NEXT: add r3, r3, r4
97 ; CHECK-P9-NEXT: slwi r4, r3, 1
98 ; CHECK-P9-NEXT: add r3, r3, r4
99 ; CHECK-P9-NEXT: sub r3, r28, r3
100 ; CHECK-P9-NEXT: cmplwi r3, 1
101 ; CHECK-P9-NEXT: beq cr0, .LBB1_1
102 ; CHECK-P9-NEXT: # %bb.5: # %while.cond
104 ; CHECK-P9-NEXT: cmplwi r3, 0
105 ; CHECK-P9-NEXT: bne cr0, .LBB1_3
106 ; CHECK-P9-NEXT: # %bb.6: # %sw.bb
108 ; CHECK-P9-NEXT: mulli r3, r29, 13
109 ; CHECK-P9-NEXT: b .LBB1_2
110 ; CHECK-P9-NEXT: .LBB1_7: # %while.end
111 ; CHECK-P9-NEXT: lis r3, -13108
112 ; CHECK-P9-NEXT: lis r4, 13107
113 ; CHECK-P9-NEXT: ori r3, r3, 52429
114 ; CHECK-P9-NEXT: ori r4, r4, 13108
115 ; CHECK-P9-NEXT: mullw r3, r28, r3
116 ; CHECK-P9-NEXT: cmplw r3, r4
117 ; CHECK-P9-NEXT: blt cr0, .LBB1_9
118 ; CHECK-P9-NEXT: # %bb.8: # %if.then8
119 ; CHECK-P9-NEXT: mulli r3, r29, 13
120 ; CHECK-P9-NEXT: mulli r5, r30, 23
121 ; CHECK-P9-NEXT: extsw r4, r28
122 ; CHECK-P9-NEXT: extsw r3, r3
123 ; CHECK-P9-NEXT: extsw r5, r5
124 ; CHECK-P9-NEXT: sub r3, r4, r3
125 ; CHECK-P9-NEXT: sub r4, r5, r4
126 ; CHECK-P9-NEXT: rldicl r3, r3, 1, 63
127 ; CHECK-P9-NEXT: rldicl r4, r4, 1, 63
128 ; CHECK-P9-NEXT: or r3, r3, r4
129 ; CHECK-P9-NEXT: b .LBB1_10
130 ; CHECK-P9-NEXT: .LBB1_9: # %cleanup20
131 ; CHECK-P9-NEXT: li r3, 0
132 ; CHECK-P9-NEXT: .LBB1_10: # %cleanup20
133 ; CHECK-P9-NEXT: addi r1, r1, 80
134 ; CHECK-P9-NEXT: ld r0, 16(r1)
135 ; CHECK-P9-NEXT: ld r30, -16(r1) # 8-byte Folded Reload
136 ; CHECK-P9-NEXT: ld r29, -24(r1) # 8-byte Folded Reload
137 ; CHECK-P9-NEXT: ld r28, -32(r1) # 8-byte Folded Reload
138 ; CHECK-P9-NEXT: mtlr r0
139 ; CHECK-P9-NEXT: ld r27, -40(r1) # 8-byte Folded Reload
142 %add = add nsw i32 %y, %x
145 while.cond: ; preds = %sw.epilog, %entry
146 %sum.0 = phi i32 [ %add, %entry ], [ %sum.1, %sw.epilog ]
147 %y.addr.0 = phi i32 [ %y, %entry ], [ %call1, %sw.epilog ]
148 %x.addr.0 = phi i32 [ %x, %entry ], [ %call, %sw.epilog ]
149 %call = tail call signext i32 @bar(i32 signext %x.addr.0) #2
150 %call1 = tail call signext i32 @bar(i32 signext %y.addr.0) #2
151 %rem = srem i32 %sum.0, 3
152 switch i32 %rem, label %sw.epilog [
157 sw.bb: ; preds = %while.cond
158 %mul = mul nsw i32 %call, 13
159 %add2 = add nsw i32 %mul, %sum.0
162 sw.bb3: ; preds = %while.cond
163 %mul4 = mul nsw i32 %call1, 23
164 %add5 = add nsw i32 %mul4, %sum.0
167 sw.epilog: ; preds = %while.cond, %sw.bb3, %sw.bb
168 %sum.1 = phi i32 [ %sum.0, %while.cond ], [ %add5, %sw.bb3 ], [ %add2, %sw.bb ]
169 %cmp = icmp slt i32 %sum.1, 1025
170 br i1 %cmp, label %while.cond, label %while.end
172 while.end: ; preds = %sw.epilog
173 %rem739 = urem i32 %sum.1, 5
174 %tobool = icmp eq i32 %rem739, 0
175 br i1 %tobool, label %cleanup20, label %if.then8
177 if.then8: ; preds = %while.end
178 %mul9 = mul nsw i32 %call, 13
179 %cmp11 = icmp slt i32 %sum.1, %mul9
180 %mul10 = mul nsw i32 %call1, 23
181 %cmp12 = icmp sgt i32 %sum.1, %mul10
182 %or.cond = or i1 %cmp11, %cmp12
183 %spec.select = zext i1 %or.cond to i32
186 cleanup20: ; preds = %while.end
190 declare signext i32 @bar(i32 signext) local_unnamed_addr #1