• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -mcpu=atom -march=x86-64 | FileCheck %s
2
3target triple = "x86_64-unknown-linux-gnu"
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: movq %rdi, %rax
10; CHECK: orq %rsi, %rax
11; CHECK-NEXT: testq $-65536, %rax
12; CHECK-NEXT: je
13; CHECK: idivq
14; CHECK: ret
15; CHECK: divw
16; CHECK: ret
17  %result = sdiv i64 %a, %b
18  ret i64 %result
19}
20
21define i64 @Test_get_remainder(i64 %a, i64 %b) nounwind {
22; CHECK-LABEL: Test_get_remainder:
23; CHECK: movq %rdi, %rax
24; CHECK: orq %rsi, %rax
25; CHECK-NEXT: testq $-65536, %rax
26; CHECK-NEXT: je
27; CHECK: idivq
28; CHECK: ret
29; CHECK: divw
30; CHECK: ret
31  %result = srem i64 %a, %b
32  ret i64 %result
33}
34
35define i64 @Test_get_quotient_and_remainder(i64 %a, i64 %b) nounwind {
36; CHECK-LABEL: Test_get_quotient_and_remainder:
37; CHECK: movq %rdi, %rax
38; CHECK: orq %rsi, %rax
39; CHECK-NEXT: testq $-65536, %rax
40; CHECK-NEXT: je
41; CHECK: idivq
42; CHECK: divw
43; CHECK: addq
44; CHECK: ret
45; CHECK-NOT: idivq
46; CHECK-NOT: divw
47  %resultdiv = sdiv i64 %a, %b
48  %resultrem = srem i64 %a, %b
49  %result = add i64 %resultdiv, %resultrem
50  ret i64 %result
51}
52