1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; Check that 64-bit division is bypassed correctly.
3 ; RUN: llc < %s -mattr=+idivq-to-divl -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
5 ; Additional tests for 64-bit divide bypass
7 define i64 @Test_get_quotient(i64 %a, i64 %b) nounwind {
8 ; CHECK-LABEL: Test_get_quotient:
10 ; CHECK-NEXT: movq %rdi, %rax
11 ; CHECK-NEXT: movq %rdi, %rcx
12 ; CHECK-NEXT: orq %rsi, %rcx
13 ; CHECK-NEXT: shrq $32, %rcx
14 ; CHECK-NEXT: je .LBB0_1
15 ; CHECK-NEXT: # %bb.2:
17 ; CHECK-NEXT: idivq %rsi
19 ; CHECK-NEXT: .LBB0_1:
20 ; CHECK-NEXT: # kill: def $eax killed $eax killed $rax
21 ; CHECK-NEXT: xorl %edx, %edx
22 ; CHECK-NEXT: divl %esi
23 ; CHECK-NEXT: # kill: def $eax killed $eax def $rax
25 %result = sdiv i64 %a, %b
29 define i64 @Test_get_remainder(i64 %a, i64 %b) nounwind {
30 ; CHECK-LABEL: Test_get_remainder:
32 ; CHECK-NEXT: movq %rdi, %rax
33 ; CHECK-NEXT: movq %rdi, %rcx
34 ; CHECK-NEXT: orq %rsi, %rcx
35 ; CHECK-NEXT: shrq $32, %rcx
36 ; CHECK-NEXT: je .LBB1_1
37 ; CHECK-NEXT: # %bb.2:
39 ; CHECK-NEXT: idivq %rsi
40 ; CHECK-NEXT: movq %rdx, %rax
42 ; CHECK-NEXT: .LBB1_1:
43 ; CHECK-NEXT: # kill: def $eax killed $eax killed $rax
44 ; CHECK-NEXT: xorl %edx, %edx
45 ; CHECK-NEXT: divl %esi
46 ; CHECK-NEXT: movl %edx, %eax
48 %result = srem i64 %a, %b
52 define i64 @Test_get_quotient_and_remainder(i64 %a, i64 %b) nounwind {
53 ; CHECK-LABEL: Test_get_quotient_and_remainder:
55 ; CHECK-NEXT: movq %rdi, %rax
56 ; CHECK-NEXT: movq %rdi, %rcx
57 ; CHECK-NEXT: orq %rsi, %rcx
58 ; CHECK-NEXT: shrq $32, %rcx
59 ; CHECK-NEXT: je .LBB2_1
60 ; CHECK-NEXT: # %bb.2:
62 ; CHECK-NEXT: idivq %rsi
63 ; CHECK-NEXT: addq %rdx, %rax
65 ; CHECK-NEXT: .LBB2_1:
66 ; CHECK-NEXT: # kill: def $eax killed $eax killed $rax
67 ; CHECK-NEXT: xorl %edx, %edx
68 ; CHECK-NEXT: divl %esi
69 ; CHECK-NEXT: # kill: def $edx killed $edx def $rdx
70 ; CHECK-NEXT: # kill: def $eax killed $eax def $rax
71 ; CHECK-NEXT: addq %rdx, %rax
73 %resultdiv = sdiv i64 %a, %b
74 %resultrem = srem i64 %a, %b
75 %result = add i64 %resultdiv, %resultrem