1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
6 ; This used to call muloti4, but that won't link with libgcc.
7 define %0 @x(i64 %a.coerce0, i64 %a.coerce1, i64 %b.coerce0, i64 %b.coerce1) nounwind uwtable ssp {
9 ; CHECK: ## %bb.0: ## %entry
10 ; CHECK-NEXT: pushq %r15
11 ; CHECK-NEXT: .cfi_def_cfa_offset 16
12 ; CHECK-NEXT: pushq %r14
13 ; CHECK-NEXT: .cfi_def_cfa_offset 24
14 ; CHECK-NEXT: pushq %rbx
15 ; CHECK-NEXT: .cfi_def_cfa_offset 32
16 ; CHECK-NEXT: .cfi_offset %rbx, -32
17 ; CHECK-NEXT: .cfi_offset %r14, -24
18 ; CHECK-NEXT: .cfi_offset %r15, -16
19 ; CHECK-NEXT: movq %rdx, %r11
20 ; CHECK-NEXT: movq %rsi, %r9
21 ; CHECK-NEXT: movq %rdi, %r15
22 ; CHECK-NEXT: sarq $63, %rsi
23 ; CHECK-NEXT: movq %rdx, %rdi
24 ; CHECK-NEXT: imulq %rsi, %rdi
25 ; CHECK-NEXT: movq %rdx, %rax
26 ; CHECK-NEXT: mulq %rsi
27 ; CHECK-NEXT: movq %rax, %r8
28 ; CHECK-NEXT: addq %rdi, %rdx
29 ; CHECK-NEXT: imulq %rcx, %rsi
30 ; CHECK-NEXT: addq %rdx, %rsi
31 ; CHECK-NEXT: movq %rcx, %rdi
32 ; CHECK-NEXT: sarq $63, %rdi
33 ; CHECK-NEXT: movq %rdi, %rbx
34 ; CHECK-NEXT: imulq %r9, %rbx
35 ; CHECK-NEXT: movq %rdi, %rax
36 ; CHECK-NEXT: mulq %r15
37 ; CHECK-NEXT: movq %rax, %r10
38 ; CHECK-NEXT: addq %rbx, %rdx
39 ; CHECK-NEXT: imulq %r15, %rdi
40 ; CHECK-NEXT: addq %rdx, %rdi
41 ; CHECK-NEXT: addq %r8, %r10
42 ; CHECK-NEXT: adcq %rsi, %rdi
43 ; CHECK-NEXT: movq %r15, %rax
44 ; CHECK-NEXT: mulq %r11
45 ; CHECK-NEXT: movq %rdx, %r14
46 ; CHECK-NEXT: movq %rax, %r8
47 ; CHECK-NEXT: movq %r9, %rax
48 ; CHECK-NEXT: mulq %r11
49 ; CHECK-NEXT: movq %rdx, %rbx
50 ; CHECK-NEXT: movq %rax, %rsi
51 ; CHECK-NEXT: addq %r14, %rsi
52 ; CHECK-NEXT: adcq $0, %rbx
53 ; CHECK-NEXT: movq %r15, %rax
54 ; CHECK-NEXT: mulq %rcx
55 ; CHECK-NEXT: movq %rdx, %r14
56 ; CHECK-NEXT: movq %rax, %r11
57 ; CHECK-NEXT: addq %rsi, %r11
58 ; CHECK-NEXT: adcq %rbx, %r14
59 ; CHECK-NEXT: setb %al
60 ; CHECK-NEXT: movzbl %al, %esi
61 ; CHECK-NEXT: movq %r9, %rax
62 ; CHECK-NEXT: mulq %rcx
63 ; CHECK-NEXT: addq %r14, %rax
64 ; CHECK-NEXT: adcq %rsi, %rdx
65 ; CHECK-NEXT: addq %r10, %rax
66 ; CHECK-NEXT: adcq %rdi, %rdx
67 ; CHECK-NEXT: movq %r11, %rcx
68 ; CHECK-NEXT: sarq $63, %rcx
69 ; CHECK-NEXT: xorq %rcx, %rdx
70 ; CHECK-NEXT: xorq %rax, %rcx
71 ; CHECK-NEXT: orq %rdx, %rcx
72 ; CHECK-NEXT: jne LBB0_1
73 ; CHECK-NEXT: ## %bb.2: ## %nooverflow
74 ; CHECK-NEXT: movq %r8, %rax
75 ; CHECK-NEXT: movq %r11, %rdx
76 ; CHECK-NEXT: popq %rbx
77 ; CHECK-NEXT: popq %r14
78 ; CHECK-NEXT: popq %r15
80 ; CHECK-NEXT: LBB0_1: ## %overflow
83 %tmp16 = zext i64 %a.coerce0 to i128
84 %tmp11 = zext i64 %a.coerce1 to i128
85 %tmp12 = shl nuw i128 %tmp11, 64
86 %ins14 = or i128 %tmp12, %tmp16
87 %tmp6 = zext i64 %b.coerce0 to i128
88 %tmp3 = zext i64 %b.coerce1 to i128
89 %tmp4 = shl nuw i128 %tmp3, 64
90 %ins = or i128 %tmp4, %tmp6
91 %0 = tail call %1 @llvm.smul.with.overflow.i128(i128 %ins14, i128 %ins)
92 %1 = extractvalue %1 %0, 0
93 %2 = extractvalue %1 %0, 1
94 br i1 %2, label %overflow, label %nooverflow
96 overflow: ; preds = %entry
97 tail call void @llvm.trap()
100 nooverflow: ; preds = %entry
101 %tmp20 = trunc i128 %1 to i64
102 %tmp21 = insertvalue %0 undef, i64 %tmp20, 0
103 %tmp22 = lshr i128 %1, 64
104 %tmp23 = trunc i128 %tmp22 to i64
105 %tmp24 = insertvalue %0 %tmp21, i64 %tmp23, 1
109 declare %1 @llvm.smul.with.overflow.i128(i128, i128) nounwind readnone
111 declare void @llvm.trap() nounwind