1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefix=X64
4 ; Verify expansion by using constant values. We just want to cover all the paths layed out by ExpandIntRes_MULFIX.
6 declare i4 @llvm.smul.fix.sat.i4 (i4, i4, i32)
7 declare i32 @llvm.smul.fix.sat.i32 (i32, i32, i32)
8 declare i64 @llvm.smul.fix.sat.i64 (i64, i64, i32)
9 declare <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32>, <4 x i32>, i32)
10 declare { i64, i1 } @llvm.smul.with.overflow.i64(i64, i64)
12 define i64 @func() nounwind {
15 ; X64-NEXT: movl $2, %ecx
16 ; X64-NEXT: movl $3, %eax
17 ; X64-NEXT: imulq %rcx
18 ; X64-NEXT: shrdq $2, %rdx, %rax
19 ; X64-NEXT: cmpq $1, %rdx
20 ; X64-NEXT: movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
21 ; X64-NEXT: cmovgq %rcx, %rax
22 ; X64-NEXT: cmpq $-2, %rdx
23 ; X64-NEXT: movabsq $-9223372036854775808, %rcx # imm = 0x8000000000000000
24 ; X64-NEXT: cmovlq %rcx, %rax
26 %tmp = call i64 @llvm.smul.fix.sat.i64(i64 3, i64 2, i32 2)
30 define i64 @func2() nounwind {
33 ; X64-NEXT: movl $3, %eax
34 ; X64-NEXT: imulq $2, %rax, %rcx
35 ; X64-NEXT: xorl %edx, %edx
36 ; X64-NEXT: testq %rcx, %rcx
38 ; X64-NEXT: movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
39 ; X64-NEXT: addq %rdx, %rcx
40 ; X64-NEXT: imulq $2, %rax, %rax
41 ; X64-NEXT: cmovoq %rcx, %rax
43 %tmp = call i64 @llvm.smul.fix.sat.i64(i64 3, i64 2, i32 0)
47 define i64 @func3() nounwind {
50 ; X64-NEXT: movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
51 ; X64-NEXT: movl $2, %edx
52 ; X64-NEXT: movq %rcx, %rax
53 ; X64-NEXT: imulq %rdx
54 ; X64-NEXT: shrdq $2, %rdx, %rax
55 ; X64-NEXT: cmpq $1, %rdx
56 ; X64-NEXT: cmovgq %rcx, %rax
57 ; X64-NEXT: cmpq $-2, %rdx
58 ; X64-NEXT: movabsq $-9223372036854775808, %rcx # imm = 0x8000000000000000
59 ; X64-NEXT: cmovlq %rcx, %rax
61 %tmp = call i64 @llvm.smul.fix.sat.i64(i64 9223372036854775807, i64 2, i32 2)
65 define i64 @func4() nounwind {
68 ; X64-NEXT: movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
69 ; X64-NEXT: movl $2, %edx
70 ; X64-NEXT: movq %rcx, %rax
71 ; X64-NEXT: imulq %rdx
72 ; X64-NEXT: shrdq $32, %rdx, %rax
73 ; X64-NEXT: cmpq $2147483647, %rdx # imm = 0x7FFFFFFF
74 ; X64-NEXT: cmovgq %rcx, %rax
75 ; X64-NEXT: cmpq $-2147483648, %rdx # imm = 0x80000000
76 ; X64-NEXT: movabsq $-9223372036854775808, %rcx # imm = 0x8000000000000000
77 ; X64-NEXT: cmovlq %rcx, %rax
79 %tmp = call i64 @llvm.smul.fix.sat.i64(i64 9223372036854775807, i64 2, i32 32)
83 define i64 @func5() nounwind {
86 ; X64-NEXT: movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
87 ; X64-NEXT: movl $2, %edx
88 ; X64-NEXT: movq %rcx, %rax
89 ; X64-NEXT: imulq %rdx
90 ; X64-NEXT: shrdq $63, %rdx, %rax
91 ; X64-NEXT: movabsq $4611686018427387903, %rsi # imm = 0x3FFFFFFFFFFFFFFF
92 ; X64-NEXT: cmpq %rsi, %rdx
93 ; X64-NEXT: cmovgq %rcx, %rax
94 ; X64-NEXT: movabsq $-4611686018427387904, %rcx # imm = 0xC000000000000000
95 ; X64-NEXT: cmpq %rcx, %rdx
96 ; X64-NEXT: movabsq $-9223372036854775808, %rcx # imm = 0x8000000000000000
97 ; X64-NEXT: cmovlq %rcx, %rax
99 %tmp = call i64 @llvm.smul.fix.sat.i64(i64 9223372036854775807, i64 2, i32 63)