2013-05-20 18:07:43 +00:00
|
|
|
; RUN: llc -march=mips < %s | FileCheck %s -check-prefix=TRAP
|
2013-05-21 17:17:59 +00:00
|
|
|
; RUN: llc -march=mips -mno-check-zero-division < %s |\
|
2013-05-20 18:07:43 +00:00
|
|
|
; RUN: FileCheck %s -check-prefix=NOCHECK
|
|
|
|
|
|
|
|
; TRAP: sdiv1:
|
|
|
|
; TRAP: div $zero, ${{[0-9]+}}, $[[R0:[0-9]+]]
|
|
|
|
; TRAP: teq $[[R0]], $zero, 7
|
|
|
|
; TRAP: mflo
|
|
|
|
|
|
|
|
; NOCHECK: sdiv1:
|
|
|
|
; NOCHECK-NOT: teq
|
|
|
|
; NOCHECK: .end sdiv1
|
2011-03-04 21:03:24 +00:00
|
|
|
|
|
|
|
define i32 @sdiv1(i32 %a0, i32 %a1) nounwind readnone {
|
|
|
|
entry:
|
|
|
|
%div = sdiv i32 %a0, %a1
|
|
|
|
ret i32 %div
|
|
|
|
}
|
|
|
|
|
2013-05-20 18:07:43 +00:00
|
|
|
; TRAP: srem1:
|
|
|
|
; TRAP: div $zero, ${{[0-9]+}}, $[[R0:[0-9]+]]
|
|
|
|
; TRAP: teq $[[R0]], $zero, 7
|
|
|
|
; TRAP: mfhi
|
|
|
|
|
2011-03-04 21:03:24 +00:00
|
|
|
define i32 @srem1(i32 %a0, i32 %a1) nounwind readnone {
|
|
|
|
entry:
|
|
|
|
%rem = srem i32 %a0, %a1
|
|
|
|
ret i32 %rem
|
|
|
|
}
|
|
|
|
|
2013-05-20 18:07:43 +00:00
|
|
|
; TRAP: udiv1:
|
|
|
|
; TRAP: divu $zero, ${{[0-9]+}}, $[[R0:[0-9]+]]
|
|
|
|
; TRAP: teq $[[R0]], $zero, 7
|
|
|
|
; TRAP: mflo
|
|
|
|
|
2011-03-04 21:03:24 +00:00
|
|
|
define i32 @udiv1(i32 %a0, i32 %a1) nounwind readnone {
|
|
|
|
entry:
|
|
|
|
%div = udiv i32 %a0, %a1
|
|
|
|
ret i32 %div
|
|
|
|
}
|
|
|
|
|
2013-05-20 18:07:43 +00:00
|
|
|
; TRAP: urem1:
|
|
|
|
; TRAP: divu $zero, ${{[0-9]+}}, $[[R0:[0-9]+]]
|
|
|
|
; TRAP: teq $[[R0]], $zero, 7
|
|
|
|
; TRAP: mfhi
|
|
|
|
|
2011-03-04 21:03:24 +00:00
|
|
|
define i32 @urem1(i32 %a0, i32 %a1) nounwind readnone {
|
|
|
|
entry:
|
|
|
|
%rem = urem i32 %a0, %a1
|
|
|
|
ret i32 %rem
|
|
|
|
}
|
|
|
|
|
2013-05-20 18:07:43 +00:00
|
|
|
; TRAP: div $zero,
|
2011-03-04 21:03:24 +00:00
|
|
|
define i32 @sdivrem1(i32 %a0, i32 %a1, i32* nocapture %r) nounwind {
|
|
|
|
entry:
|
|
|
|
%rem = srem i32 %a0, %a1
|
2013-04-30 17:52:57 +00:00
|
|
|
store i32 %rem, i32* %r, align 4
|
2011-03-04 21:03:24 +00:00
|
|
|
%div = sdiv i32 %a0, %a1
|
|
|
|
ret i32 %div
|
|
|
|
}
|
|
|
|
|
2013-05-20 18:07:43 +00:00
|
|
|
; TRAP: divu $zero,
|
2011-03-04 21:03:24 +00:00
|
|
|
define i32 @udivrem1(i32 %a0, i32 %a1, i32* nocapture %r) nounwind {
|
|
|
|
entry:
|
|
|
|
%rem = urem i32 %a0, %a1
|
2013-04-30 17:52:57 +00:00
|
|
|
store i32 %rem, i32* %r, align 4
|
2011-03-04 21:03:24 +00:00
|
|
|
%div = udiv i32 %a0, %a1
|
|
|
|
ret i32 %div
|
|
|
|
}
|