aboutsummaryrefslogtreecommitdiffstats
path: root/test/CodeGen/Mips/divrem.ll
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@mips.com>2013-05-20 18:07:43 +0000
committerAkira Hatanaka <ahatanaka@mips.com>2013-05-20 18:07:43 +0000
commitf894199a14fff1399f6ee9d78c6a601d86649155 (patch)
treeee79d0a41679fe70d5b58e34140d0ec43dcbdc4c /test/CodeGen/Mips/divrem.ll
parent08f92c98ac1cdb43ec35653536c89964401d936c (diff)
downloadexternal_llvm-f894199a14fff1399f6ee9d78c6a601d86649155.zip
external_llvm-f894199a14fff1399f6ee9d78c6a601d86649155.tar.gz
external_llvm-f894199a14fff1399f6ee9d78c6a601d86649155.tar.bz2
[mips] Trap on integer division by zero.
By default, a teq instruction is inserted after integer divide. No divide-by-zero checks are performed if option "-mnocheck-zero-division" is used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182306 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/Mips/divrem.ll')
-rw-r--r--test/CodeGen/Mips/divrem.ll36
1 files changed, 29 insertions, 7 deletions
diff --git a/test/CodeGen/Mips/divrem.ll b/test/CodeGen/Mips/divrem.ll
index c470d1c..d221501 100644
--- a/test/CodeGen/Mips/divrem.ll
+++ b/test/CodeGen/Mips/divrem.ll
@@ -1,34 +1,56 @@
-; RUN: llc -march=mips < %s | FileCheck %s
+; RUN: llc -march=mips < %s | FileCheck %s -check-prefix=TRAP
+; RUN: llc -march=mips -mnocheck-zero-division < %s |\
+; 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
-; CHECK: div $zero,
define i32 @sdiv1(i32 %a0, i32 %a1) nounwind readnone {
entry:
%div = sdiv i32 %a0, %a1
ret i32 %div
}
-; CHECK: div $zero,
+; TRAP: srem1:
+; TRAP: div $zero, ${{[0-9]+}}, $[[R0:[0-9]+]]
+; TRAP: teq $[[R0]], $zero, 7
+; TRAP: mfhi
+
define i32 @srem1(i32 %a0, i32 %a1) nounwind readnone {
entry:
%rem = srem i32 %a0, %a1
ret i32 %rem
}
-; CHECK: divu $zero,
+; TRAP: udiv1:
+; TRAP: divu $zero, ${{[0-9]+}}, $[[R0:[0-9]+]]
+; TRAP: teq $[[R0]], $zero, 7
+; TRAP: mflo
+
define i32 @udiv1(i32 %a0, i32 %a1) nounwind readnone {
entry:
%div = udiv i32 %a0, %a1
ret i32 %div
}
-; CHECK: divu $zero,
+; TRAP: urem1:
+; TRAP: divu $zero, ${{[0-9]+}}, $[[R0:[0-9]+]]
+; TRAP: teq $[[R0]], $zero, 7
+; TRAP: mfhi
+
define i32 @urem1(i32 %a0, i32 %a1) nounwind readnone {
entry:
%rem = urem i32 %a0, %a1
ret i32 %rem
}
-; CHECK: div $zero,
+; TRAP: div $zero,
define i32 @sdivrem1(i32 %a0, i32 %a1, i32* nocapture %r) nounwind {
entry:
%rem = srem i32 %a0, %a1
@@ -37,7 +59,7 @@ entry:
ret i32 %div
}
-; CHECK: divu $zero,
+; TRAP: divu $zero,
define i32 @udivrem1(i32 %a0, i32 %a1, i32* nocapture %r) nounwind {
entry:
%rem = urem i32 %a0, %a1