diff options
author | Petar Jovanovic <petar.jovanovic@rt-rk.com> | 2013-10-11 02:58:15 +0200 |
---|---|---|
committer | Petar Jovanovic <petar.jovanovic@rt-rk.com> | 2013-10-11 02:58:15 +0200 |
commit | 1b783c13dd573e2611f7fde92e3e66475bdb8918 (patch) | |
tree | 66dc28910692ae2a59fc47b758cb477de3f20e55 /test | |
parent | 0588a8b5d075090adb3bd16fafd16a43d6125784 (diff) |
Apply upstream: [mips] Trap on integer division by zero.
Cherry-pick r182306 from upstream.
Original commit message:
Author: Akira Hatanaka <ahatanaka@mips.com>
Date: Mon May 20 18:07:43 2013 +0000
[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.
TBR= mseaborn@chromium.org, dschuff@chromium.org
BUG= missing trap for MIPS
Review URL: https://codereview.chromium.org/26846007
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/Mips/divrem.ll | 36 | ||||
-rw-r--r-- | test/CodeGen/Mips/mips64instrs.ll | 16 |
2 files changed, 41 insertions, 11 deletions
diff --git a/test/CodeGen/Mips/divrem.ll b/test/CodeGen/Mips/divrem.ll index c470d1ce2c..d221501a31 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 diff --git a/test/CodeGen/Mips/mips64instrs.ll b/test/CodeGen/Mips/mips64instrs.ll index 0418311490..2e3df3a0a8 100644 --- a/test/CodeGen/Mips/mips64instrs.ll +++ b/test/CodeGen/Mips/mips64instrs.ll @@ -86,7 +86,9 @@ entry: define i64 @f14(i64 %a, i64 %b) nounwind readnone { entry: -; CHECK: ddiv $zero +; CHECK: f14: +; CHECK: ddiv $zero, ${{[0-9]+}}, $[[R0:[0-9]+]] +; CHECK: teq $[[R0]], $zero, 7 ; CHECK: mflo %div = sdiv i64 %a, %b ret i64 %div @@ -94,7 +96,9 @@ entry: define i64 @f15(i64 %a, i64 %b) nounwind readnone { entry: -; CHECK: ddivu $zero +; CHECK: f15: +; CHECK: ddivu $zero, ${{[0-9]+}}, $[[R0:[0-9]+]] +; CHECK: teq $[[R0]], $zero, 7 ; CHECK: mflo %div = udiv i64 %a, %b ret i64 %div @@ -102,7 +106,9 @@ entry: define i64 @f16(i64 %a, i64 %b) nounwind readnone { entry: -; CHECK: ddiv $zero +; CHECK: f16: +; CHECK: ddiv $zero, ${{[0-9]+}}, $[[R0:[0-9]+]] +; CHECK: teq $[[R0]], $zero, 7 ; CHECK: mfhi %rem = srem i64 %a, %b ret i64 %rem @@ -110,7 +116,9 @@ entry: define i64 @f17(i64 %a, i64 %b) nounwind readnone { entry: -; CHECK: ddivu $zero +; CHECK: f17: +; CHECK: ddivu $zero, ${{[0-9]+}}, $[[R0:[0-9]+]] +; CHECK: teq $[[R0]], $zero, 7 ; CHECK: mfhi %rem = urem i64 %a, %b ret i64 %rem |