1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s --check-prefixes=PPC64
3; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu | FileCheck %s --check-prefixes=PPC32
4
5define { i128, i8 } @muloti_test(i128 %l, i128 %r) unnamed_addr #0 {
6; PPC64-LABEL: muloti_test:
7; PPC64:       # %bb.0: # %start
8; PPC64-NEXT:    mulhdu. 8, 3, 6
9; PPC64-NEXT:    mcrf 1, 0
10; PPC64-NEXT:    mulld 8, 5, 4
11; PPC64-NEXT:    cmpdi 3, 0
12; PPC64-NEXT:    mulld 3, 3, 6
13; PPC64-NEXT:    cmpdi 5, 5, 0
14; PPC64-NEXT:    add 3, 3, 8
15; PPC64-NEXT:    crnor 20, 22, 2
16; PPC64-NEXT:    mulhdu 8, 4, 6
17; PPC64-NEXT:    cmpldi 3, 0
18; PPC64-NEXT:    add 3, 8, 3
19; PPC64-NEXT:    cmpld 6, 3, 8
20; PPC64-NEXT:    crandc 21, 24, 2
21; PPC64-NEXT:    crorc 20, 20, 6
22; PPC64-NEXT:    mulhdu. 5, 5, 4
23; PPC64-NEXT:    crorc 20, 20, 2
24; PPC64-NEXT:    li 7, 1
25; PPC64-NEXT:    crnor 20, 20, 21
26; PPC64-NEXT:    mulld 4, 4, 6
27; PPC64-NEXT:    bc 12, 20, .LBB0_2
28; PPC64-NEXT:  # %bb.1: # %start
29; PPC64-NEXT:    ori 5, 7, 0
30; PPC64-NEXT:    blr
31; PPC64-NEXT:  .LBB0_2: # %start
32; PPC64-NEXT:    li 5, 0
33; PPC64-NEXT:    blr
34;
35; PPC32-LABEL: muloti_test:
36; PPC32:       # %bb.0: # %start
37; PPC32-NEXT:    mflr 0
38; PPC32-NEXT:    stw 0, 4(1)
39; PPC32-NEXT:    stwu 1, -80(1)
40; PPC32-NEXT:    stw 26, 56(1) # 4-byte Folded Spill
41; PPC32-NEXT:    mfcr 12
42; PPC32-NEXT:    stw 27, 60(1) # 4-byte Folded Spill
43; PPC32-NEXT:    mr 27, 4
44; PPC32-NEXT:    stw 29, 68(1) # 4-byte Folded Spill
45; PPC32-NEXT:    mr 29, 7
46; PPC32-NEXT:    stw 30, 72(1) # 4-byte Folded Spill
47; PPC32-NEXT:    mr 30, 8
48; PPC32-NEXT:    mr 26, 3
49; PPC32-NEXT:    li 3, 0
50; PPC32-NEXT:    li 4, 0
51; PPC32-NEXT:    li 7, 0
52; PPC32-NEXT:    li 8, 0
53; PPC32-NEXT:    stw 20, 32(1) # 4-byte Folded Spill
54; PPC32-NEXT:    stw 21, 36(1) # 4-byte Folded Spill
55; PPC32-NEXT:    stw 22, 40(1) # 4-byte Folded Spill
56; PPC32-NEXT:    stw 23, 44(1) # 4-byte Folded Spill
57; PPC32-NEXT:    mr 23, 6
58; PPC32-NEXT:    stw 24, 48(1) # 4-byte Folded Spill
59; PPC32-NEXT:    mr 24, 5
60; PPC32-NEXT:    stw 25, 52(1) # 4-byte Folded Spill
61; PPC32-NEXT:    mr 25, 10
62; PPC32-NEXT:    stw 28, 64(1) # 4-byte Folded Spill
63; PPC32-NEXT:    mr 28, 9
64; PPC32-NEXT:    stw 12, 28(1)
65; PPC32-NEXT:    bl __multi3
66; PPC32-NEXT:    mr 7, 4
67; PPC32-NEXT:    mullw 4, 24, 30
68; PPC32-NEXT:    cmpwi 5, 24, 0
69; PPC32-NEXT:    cmpwi 6, 26, 0
70; PPC32-NEXT:    cmpwi 7, 28, 0
71; PPC32-NEXT:    crnor 9, 30, 26
72; PPC32-NEXT:    mullw 8, 29, 23
73; PPC32-NEXT:    add 21, 8, 4
74; PPC32-NEXT:    mullw 11, 28, 27
75; PPC32-NEXT:    mullw 12, 26, 25
76; PPC32-NEXT:    add 11, 12, 11
77; PPC32-NEXT:    cmplwi 7, 11, 0
78; PPC32-NEXT:    mulhwu 9, 30, 23
79; PPC32-NEXT:    add 12, 9, 21
80; PPC32-NEXT:    cmplw 6, 12, 9
81; PPC32-NEXT:    mulhwu 10, 27, 25
82; PPC32-NEXT:    mullw 0, 30, 23
83; PPC32-NEXT:    mullw 22, 27, 25
84; PPC32-NEXT:    addc 4, 22, 0
85; PPC32-NEXT:    add 0, 10, 11
86; PPC32-NEXT:    adde 8, 0, 12
87; PPC32-NEXT:    addc 4, 7, 4
88; PPC32-NEXT:    adde 8, 3, 8
89; PPC32-NEXT:    xor 22, 4, 7
90; PPC32-NEXT:    xor 20, 8, 3
91; PPC32-NEXT:    or. 22, 22, 20
92; PPC32-NEXT:    mcrf 1, 0
93; PPC32-NEXT:    cmpwi 29, 0
94; PPC32-NEXT:    crnor 8, 22, 2
95; PPC32-NEXT:    mulhwu. 23, 29, 23
96; PPC32-NEXT:    mcrf 5, 0
97; PPC32-NEXT:    cmplwi 21, 0
98; PPC32-NEXT:    crandc 10, 24, 2
99; PPC32-NEXT:    cmplw 3, 0, 10
100; PPC32-NEXT:    crandc 11, 12, 30
101; PPC32-NEXT:    mulhwu. 9, 24, 30
102; PPC32-NEXT:    mcrf 6, 0
103; PPC32-NEXT:    cmplw 4, 7
104; PPC32-NEXT:    cmplw 7, 8, 3
105; PPC32-NEXT:    crand 12, 30, 0
106; PPC32-NEXT:    crandc 13, 28, 30
107; PPC32-NEXT:    mulhwu. 3, 26, 25
108; PPC32-NEXT:    mcrf 7, 0
109; PPC32-NEXT:    cror 0, 12, 13
110; PPC32-NEXT:    crandc 12, 0, 6
111; PPC32-NEXT:    crorc 20, 8, 22
112; PPC32-NEXT:    crorc 20, 20, 26
113; PPC32-NEXT:    mulhwu. 3, 28, 27
114; PPC32-NEXT:    mcrf 1, 0
115; PPC32-NEXT:    crorc 25, 9, 30
116; PPC32-NEXT:    or. 3, 27, 26
117; PPC32-NEXT:    cror 24, 20, 10
118; PPC32-NEXT:    mcrf 5, 0
119; PPC32-NEXT:    crorc 25, 25, 6
120; PPC32-NEXT:    or. 3, 30, 29
121; PPC32-NEXT:    cror 25, 25, 11
122; PPC32-NEXT:    crnor 20, 2, 22
123; PPC32-NEXT:    lwz 12, 28(1)
124; PPC32-NEXT:    cror 20, 20, 25
125; PPC32-NEXT:    cror 20, 20, 24
126; PPC32-NEXT:    crnor 20, 20, 12
127; PPC32-NEXT:    li 3, 1
128; PPC32-NEXT:    bc 12, 20, .LBB0_2
129; PPC32-NEXT:  # %bb.1: # %start
130; PPC32-NEXT:    ori 7, 3, 0
131; PPC32-NEXT:    b .LBB0_3
132; PPC32-NEXT:  .LBB0_2: # %start
133; PPC32-NEXT:    li 7, 0
134; PPC32-NEXT:  .LBB0_3: # %start
135; PPC32-NEXT:    mr 3, 8
136; PPC32-NEXT:    mtcrf 32, 12 # cr2
137; PPC32-NEXT:    mtcrf 16, 12 # cr3
138; PPC32-NEXT:    lwz 30, 72(1) # 4-byte Folded Reload
139; PPC32-NEXT:    lwz 29, 68(1) # 4-byte Folded Reload
140; PPC32-NEXT:    lwz 28, 64(1) # 4-byte Folded Reload
141; PPC32-NEXT:    lwz 27, 60(1) # 4-byte Folded Reload
142; PPC32-NEXT:    lwz 26, 56(1) # 4-byte Folded Reload
143; PPC32-NEXT:    lwz 25, 52(1) # 4-byte Folded Reload
144; PPC32-NEXT:    lwz 24, 48(1) # 4-byte Folded Reload
145; PPC32-NEXT:    lwz 23, 44(1) # 4-byte Folded Reload
146; PPC32-NEXT:    lwz 22, 40(1) # 4-byte Folded Reload
147; PPC32-NEXT:    lwz 21, 36(1) # 4-byte Folded Reload
148; PPC32-NEXT:    lwz 20, 32(1) # 4-byte Folded Reload
149; PPC32-NEXT:    lwz 0, 84(1)
150; PPC32-NEXT:    addi 1, 1, 80
151; PPC32-NEXT:    mtlr 0
152; PPC32-NEXT:    blr
153start:
154  %0 = tail call { i128, i1 } @llvm.umul.with.overflow.i128(i128 %l, i128 %r) #2
155  %1 = extractvalue { i128, i1 } %0, 0
156  %2 = extractvalue { i128, i1 } %0, 1
157  %3 = zext i1 %2 to i8
158  %4 = insertvalue { i128, i8 } undef, i128 %1, 0
159  %5 = insertvalue { i128, i8 } %4, i8 %3, 1
160  ret { i128, i8 } %5
161}
162
163; Function Attrs: nounwind readnone speculatable
164declare { i128, i1 } @llvm.umul.with.overflow.i128(i128, i128) #1
165
166attributes #0 = { nounwind readnone }
167attributes #1 = { nounwind readnone speculatable }
168attributes #2 = { nounwind }
169