• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+idivl-to-divb < %s | FileCheck -check-prefix=DIV32 %s
2; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+idivq-to-divw < %s | FileCheck -check-prefix=DIV64 %s
3
4define i32 @div32(i32 %a, i32 %b) {
5entry:
6; DIV32-LABEL: div32:
7; DIV32: orl %{{.*}}, [[REG:%[a-z]+]]
8; DIV32: testl $-256, [[REG]]
9; DIV32: divb
10; DIV64-LABEL: div32:
11; DIV64-NOT: divb
12  %div = sdiv i32 %a, %b
13  ret i32 %div
14}
15
16define i64 @div64(i64 %a, i64 %b) {
17entry:
18; DIV32-LABEL: div64:
19; DIV32-NOT: divw
20; DIV64-LABEL: div64:
21; DIV64: orq %{{.*}}, [[REG:%[a-z]+]]
22; DIV64: testq   $-65536, [[REG]]
23; DIV64: divw
24  %div = sdiv i64 %a, %b
25  ret i64 %div
26}
27
28; Verify that no extra code is generated when optimizing for size.
29
30define i32 @div32_optsize(i32 %a, i32 %b) optsize {
31; DIV32-LABEL: div32_optsize:
32; DIV32-NOT: divb
33  %div = sdiv i32 %a, %b
34  ret i32 %div
35}
36
37define i32 @div32_minsize(i32 %a, i32 %b) minsize {
38; DIV32-LABEL: div32_minsize:
39; DIV32-NOT: divb
40  %div = sdiv i32 %a, %b
41  ret i32 %div
42}
43
44