• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4
5; Additional tests for 64-bit divide bypass
6
7define i64 @Test_get_quotient(i64 %a, i64 %b) nounwind {
8; CHECK-LABEL: Test_get_quotient:
9; CHECK:       # %bb.0:
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:
16; CHECK-NEXT:    cqto
17; CHECK-NEXT:    idivq %rsi
18; CHECK-NEXT:    retq
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
24; CHECK-NEXT:    retq
25  %result = sdiv i64 %a, %b
26  ret i64 %result
27}
28
29define i64 @Test_get_remainder(i64 %a, i64 %b) nounwind {
30; CHECK-LABEL: Test_get_remainder:
31; CHECK:       # %bb.0:
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:
38; CHECK-NEXT:    cqto
39; CHECK-NEXT:    idivq %rsi
40; CHECK-NEXT:    movq %rdx, %rax
41; CHECK-NEXT:    retq
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
47; CHECK-NEXT:    retq
48  %result = srem i64 %a, %b
49  ret i64 %result
50}
51
52define i64 @Test_get_quotient_and_remainder(i64 %a, i64 %b) nounwind {
53; CHECK-LABEL: Test_get_quotient_and_remainder:
54; CHECK:       # %bb.0:
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:
61; CHECK-NEXT:    cqto
62; CHECK-NEXT:    idivq %rsi
63; CHECK-NEXT:    addq %rdx, %rax
64; CHECK-NEXT:    retq
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
72; CHECK-NEXT:    retq
73  %resultdiv = sdiv i64 %a, %b
74  %resultrem = srem i64 %a, %b
75  %result = add i64 %resultdiv, %resultrem
76  ret i64 %result
77}
78
79define void @PR43514(i32 %x, i32 %y) {
80; CHECK-LABEL: PR43514:
81; CHECK:       # %bb.0:
82; CHECK-NEXT:    retq
83  %z1 = zext i32 %x to i64
84  %z2 = zext i32 %y to i64
85  %s = srem i64 %z1, %z2
86  ret void
87}
88