2017-01-13 03:48:01 +08:00
|
|
|
; Check that a division is bypassed when appropriate only.
|
|
|
|
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=atom < %s | FileCheck -check-prefixes=ATOM,CHECK %s
|
|
|
|
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=silvermont < %s | FileCheck -check-prefixes=REST,CHECK %s
|
|
|
|
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s | FileCheck -check-prefixes=REST,CHECK %s
|
2014-11-21 19:19:34 +08:00
|
|
|
|
2017-01-13 03:48:01 +08:00
|
|
|
; Verify that div32 is bypassed only for Atoms.
|
2014-11-21 19:19:34 +08:00
|
|
|
define i32 @div32(i32 %a, i32 %b) {
|
|
|
|
entry:
|
2017-01-13 03:48:01 +08:00
|
|
|
; ATOM-LABEL: div32:
|
|
|
|
; ATOM: orl %{{.*}}, [[REG:%[a-z]+]]
|
|
|
|
; ATOM: testl $-256, [[REG]]
|
|
|
|
; ATOM: divb
|
|
|
|
;
|
|
|
|
; REST-LABEL: div32:
|
|
|
|
; REST-NOT: divb
|
|
|
|
;
|
2014-11-21 19:19:34 +08:00
|
|
|
%div = sdiv i32 %a, %b
|
|
|
|
ret i32 %div
|
|
|
|
}
|
|
|
|
|
2017-01-13 03:48:01 +08:00
|
|
|
; Verify that div64 is always bypassed.
|
2014-11-21 19:19:34 +08:00
|
|
|
define i64 @div64(i64 %a, i64 %b) {
|
|
|
|
entry:
|
2017-01-13 03:48:01 +08:00
|
|
|
; CHECK-LABEL: div64:
|
2017-01-13 03:54:27 +08:00
|
|
|
; CHECK: orq %{{.*}}, [[REG:%[a-z]+]]
|
|
|
|
; CHECK: shrq $32, [[REG]]
|
2017-01-13 03:48:01 +08:00
|
|
|
; CHECK: divl
|
|
|
|
;
|
2014-11-21 19:19:34 +08:00
|
|
|
%div = sdiv i64 %a, %b
|
|
|
|
ret i64 %div
|
|
|
|
}
|
|
|
|
|
2017-01-13 03:48:01 +08:00
|
|
|
|
2015-08-12 03:39:36 +08:00
|
|
|
; Verify that no extra code is generated when optimizing for size.
|
|
|
|
|
2017-01-13 03:48:01 +08:00
|
|
|
define i64 @div64_optsize(i64 %a, i64 %b) optsize {
|
|
|
|
; CHECK-LABEL: div64_optsize:
|
|
|
|
; CHECK-NOT: divl
|
|
|
|
%div = sdiv i64 %a, %b
|
|
|
|
ret i64 %div
|
|
|
|
}
|
|
|
|
|
2015-08-12 03:39:36 +08:00
|
|
|
define i32 @div32_optsize(i32 %a, i32 %b) optsize {
|
2017-01-13 03:48:01 +08:00
|
|
|
; CHECK-LABEL: div32_optsize:
|
|
|
|
; CHECK-NOT: divb
|
2015-08-12 03:39:36 +08:00
|
|
|
%div = sdiv i32 %a, %b
|
|
|
|
ret i32 %div
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @div32_minsize(i32 %a, i32 %b) minsize {
|
2017-01-13 03:48:01 +08:00
|
|
|
; CHECK-LABEL: div32_minsize:
|
|
|
|
; CHECK-NOT: divb
|
2015-08-12 03:39:36 +08:00
|
|
|
%div = sdiv i32 %a, %b
|
|
|
|
ret i32 %div
|
|
|
|
}
|