2017-01-13 03:29:18 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2017-01-13 03:48:01 +08:00
|
|
|
; Check that 64-bit division is bypassed correctly.
|
|
|
|
; RUN: llc < %s -mattr=+idivq-to-divl -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
|
2013-03-05 02:13:57 +08:00
|
|
|
|
|
|
|
; Additional tests for 64-bit divide bypass
|
|
|
|
|
|
|
|
define i64 @Test_get_quotient(i64 %a, i64 %b) nounwind {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: Test_get_quotient:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2017-01-13 03:29:18 +08:00
|
|
|
; CHECK-NEXT: movq %rdi, %rax
|
|
|
|
; CHECK-NEXT: orq %rsi, %rax
|
2017-01-13 03:54:27 +08:00
|
|
|
; CHECK-NEXT: shrq $32, %rax
|
2017-01-13 03:29:18 +08:00
|
|
|
; CHECK-NEXT: je .LBB0_1
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK-NEXT: # %bb.2:
|
2017-01-13 03:29:18 +08:00
|
|
|
; CHECK-NEXT: movq %rdi, %rax
|
|
|
|
; CHECK-NEXT: cqto
|
|
|
|
; CHECK-NEXT: idivq %rsi
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
; CHECK-NEXT: .LBB0_1:
|
|
|
|
; CHECK-NEXT: xorl %edx, %edx
|
|
|
|
; CHECK-NEXT: movl %edi, %eax
|
2017-01-13 03:34:15 +08:00
|
|
|
; CHECK-NEXT: divl %esi
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK-NEXT: # kill: def $eax killed $eax def $rax
|
2017-01-13 03:29:18 +08:00
|
|
|
; CHECK-NEXT: retq
|
2013-03-05 02:13:57 +08:00
|
|
|
%result = sdiv i64 %a, %b
|
|
|
|
ret i64 %result
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @Test_get_remainder(i64 %a, i64 %b) nounwind {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: Test_get_remainder:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2017-01-13 03:29:18 +08:00
|
|
|
; CHECK-NEXT: movq %rdi, %rax
|
|
|
|
; CHECK-NEXT: orq %rsi, %rax
|
2017-01-13 03:54:27 +08:00
|
|
|
; CHECK-NEXT: shrq $32, %rax
|
2017-01-13 03:29:18 +08:00
|
|
|
; CHECK-NEXT: je .LBB1_1
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK-NEXT: # %bb.2:
|
2017-01-13 03:29:18 +08:00
|
|
|
; CHECK-NEXT: movq %rdi, %rax
|
|
|
|
; CHECK-NEXT: cqto
|
|
|
|
; CHECK-NEXT: idivq %rsi
|
|
|
|
; CHECK-NEXT: movq %rdx, %rax
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
; CHECK-NEXT: .LBB1_1:
|
|
|
|
; CHECK-NEXT: xorl %edx, %edx
|
|
|
|
; CHECK-NEXT: movl %edi, %eax
|
2017-01-13 03:34:15 +08:00
|
|
|
; CHECK-NEXT: divl %esi
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK-NEXT: # kill: def $edx killed $edx def $rdx
|
2017-01-13 03:34:15 +08:00
|
|
|
; CHECK-NEXT: movq %rdx, %rax
|
2017-01-13 03:29:18 +08:00
|
|
|
; CHECK-NEXT: retq
|
2013-03-05 02:13:57 +08:00
|
|
|
%result = srem i64 %a, %b
|
|
|
|
ret i64 %result
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @Test_get_quotient_and_remainder(i64 %a, i64 %b) nounwind {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: Test_get_quotient_and_remainder:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: # %bb.0:
|
2017-01-13 03:29:18 +08:00
|
|
|
; CHECK-NEXT: movq %rdi, %rax
|
|
|
|
; CHECK-NEXT: orq %rsi, %rax
|
2017-01-13 03:54:27 +08:00
|
|
|
; CHECK-NEXT: shrq $32, %rax
|
2017-01-13 03:29:18 +08:00
|
|
|
; CHECK-NEXT: je .LBB2_1
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK-NEXT: # %bb.2:
|
2017-01-13 03:29:18 +08:00
|
|
|
; CHECK-NEXT: movq %rdi, %rax
|
|
|
|
; CHECK-NEXT: cqto
|
|
|
|
; CHECK-NEXT: idivq %rsi
|
|
|
|
; CHECK-NEXT: addq %rdx, %rax
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
; CHECK-NEXT: .LBB2_1:
|
|
|
|
; CHECK-NEXT: xorl %edx, %edx
|
|
|
|
; CHECK-NEXT: movl %edi, %eax
|
2017-01-13 03:34:15 +08:00
|
|
|
; CHECK-NEXT: divl %esi
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK-NEXT: # kill: def $edx killed $edx def $rdx
|
|
|
|
; CHECK-NEXT: # kill: def $eax killed $eax def $rax
|
2017-01-13 03:29:18 +08:00
|
|
|
; CHECK-NEXT: addq %rdx, %rax
|
|
|
|
; CHECK-NEXT: retq
|
2013-03-05 02:13:57 +08:00
|
|
|
%resultdiv = sdiv i64 %a, %b
|
|
|
|
%resultrem = srem i64 %a, %b
|
|
|
|
%result = add i64 %resultdiv, %resultrem
|
|
|
|
ret i64 %result
|
|
|
|
}
|