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 %r14
11 ; CHECK-NEXT: .cfi_def_cfa_offset 16
12 ; CHECK-NEXT: pushq %rbx
13 ; CHECK-NEXT: .cfi_def_cfa_offset 24
14 ; CHECK-NEXT: .cfi_offset %rbx, -24
15 ; CHECK-NEXT: .cfi_offset %r14, -16
16 ; CHECK-NEXT: movq %rdx, %r11
17 ; CHECK-NEXT: movq %rdi, %r10
18 ; CHECK-NEXT: movq %rsi, %rdx
19 ; CHECK-NEXT: sarq $63, %rdx
20 ; CHECK-NEXT: movq %rcx, %rdi
21 ; CHECK-NEXT: imulq %rdx, %rdi
22 ; CHECK-NEXT: movq %r11, %rax
23 ; CHECK-NEXT: mulq %rdx
24 ; CHECK-NEXT: movq %rdx, %r9
25 ; CHECK-NEXT: movq %rax, %rbx
26 ; CHECK-NEXT: addq %rax, %r9
27 ; CHECK-NEXT: addq %rdi, %r9
28 ; CHECK-NEXT: movq %rcx, %rax
29 ; CHECK-NEXT: sarq $63, %rax
30 ; CHECK-NEXT: movq %rax, %r14
31 ; CHECK-NEXT: imulq %rsi, %r14
32 ; CHECK-NEXT: mulq %r10
33 ; CHECK-NEXT: movq %rax, %r8
34 ; CHECK-NEXT: movq %rdx, %rdi
35 ; CHECK-NEXT: addq %r14, %rdi
36 ; CHECK-NEXT: addq %rax, %rdi
37 ; CHECK-NEXT: addq %rbx, %r8
38 ; CHECK-NEXT: adcq %r9, %rdi
39 ; CHECK-NEXT: movq %r10, %rax
40 ; CHECK-NEXT: mulq %r11
41 ; CHECK-NEXT: movq %rdx, %rbx
42 ; CHECK-NEXT: movq %rax, %r9
43 ; CHECK-NEXT: movq %rsi, %rax
44 ; CHECK-NEXT: mulq %r11
45 ; CHECK-NEXT: movq %rdx, %r11
46 ; CHECK-NEXT: movq %rax, %r14
47 ; CHECK-NEXT: addq %rbx, %r14
48 ; CHECK-NEXT: adcq $0, %r11
49 ; CHECK-NEXT: movq %r10, %rax
50 ; CHECK-NEXT: mulq %rcx
51 ; CHECK-NEXT: movq %rdx, %rbx
52 ; CHECK-NEXT: movq %rax, %r10
53 ; CHECK-NEXT: addq %r14, %r10
54 ; CHECK-NEXT: adcq %r11, %rbx
55 ; CHECK-NEXT: setb %al
56 ; CHECK-NEXT: movzbl %al, %r11d
57 ; CHECK-NEXT: movq %rsi, %rax
58 ; CHECK-NEXT: mulq %rcx
59 ; CHECK-NEXT: addq %rbx, %rax
60 ; CHECK-NEXT: adcq %r11, %rdx
61 ; CHECK-NEXT: addq %r8, %rax
62 ; CHECK-NEXT: adcq %rdi, %rdx
63 ; CHECK-NEXT: movq %r10, %rcx
64 ; CHECK-NEXT: sarq $63, %rcx
65 ; CHECK-NEXT: xorq %rcx, %rdx
66 ; CHECK-NEXT: xorq %rax, %rcx
67 ; CHECK-NEXT: orq %rdx, %rcx
68 ; CHECK-NEXT: jne LBB0_1
69 ; CHECK-NEXT: ## %bb.2: ## %nooverflow
70 ; CHECK-NEXT: movq %r9, %rax
71 ; CHECK-NEXT: movq %r10, %rdx
72 ; CHECK-NEXT: popq %rbx
73 ; CHECK-NEXT: popq %r14
75 ; CHECK-NEXT: LBB0_1: ## %overflow
78 %tmp16 = zext i64 %a.coerce0 to i128
79 %tmp11 = zext i64 %a.coerce1 to i128
80 %tmp12 = shl nuw i128 %tmp11, 64
81 %ins14 = or i128 %tmp12, %tmp16
82 %tmp6 = zext i64 %b.coerce0 to i128
83 %tmp3 = zext i64 %b.coerce1 to i128
84 %tmp4 = shl nuw i128 %tmp3, 64
85 %ins = or i128 %tmp4, %tmp6
86 %0 = tail call %1 @llvm.smul.with.overflow.i128(i128 %ins14, i128 %ins)
87 %1 = extractvalue %1 %0, 0
88 %2 = extractvalue %1 %0, 1
89 br i1 %2, label %overflow, label %nooverflow
91 overflow: ; preds = %entry
92 tail call void @llvm.trap()
95 nooverflow: ; preds = %entry
96 %tmp20 = trunc i128 %1 to i64
97 %tmp21 = insertvalue %0 undef, i64 %tmp20, 0
98 %tmp22 = lshr i128 %1, 64
99 %tmp23 = trunc i128 %tmp22 to i64
100 %tmp24 = insertvalue %0 %tmp21, i64 %tmp23, 1
104 declare %1 @llvm.smul.with.overflow.i128(i128, i128) nounwind readnone
106 declare void @llvm.trap() nounwind