blob: b80b24993133a3d50876e90bdb0f13f18eb77357 [file] [log] [blame]
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -07001; This tests the basic structure of the Unreachable instruction.
2
Jan Voung6ec369e2015-06-30 11:03:15 -07003; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \
4; RUN: --target x8632 -i %s --args -O2 \
5; RUN: | %if --need=target_X8632 --command FileCheck %s
6; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \
7; RUN: --target x8632 -i %s --args -Om1 \
8; RUN: | %if --need=target_X8632 --command FileCheck %s
9
Jim Stichnoth033dda72016-10-03 07:56:25 -070010; RUN: %if --need=target_ARM32 \
11; RUN: --command %p2i --filetype=obj \
12; RUN: --disassemble --target arm32 -i %s --args -O2 \
13; RUN: | %if --need=target_ARM32 \
Jan Voung6ec369e2015-06-30 11:03:15 -070014; RUN: --command FileCheck --check-prefix ARM32 %s
Jim Stichnoth033dda72016-10-03 07:56:25 -070015; RUN: %if --need=target_ARM32 \
16; RUN: --command %p2i --filetype=obj \
17; RUN: --disassemble --target arm32 -i %s --args -Om1 \
18; RUN: | %if --need=target_ARM32 \
Jan Voung70fa5252015-07-06 14:01:25 -070019; RUN: --command FileCheck --check-prefix ARM32 %s
Jan Voungdddc3062014-08-29 12:59:02 -070020
Srdjan Obucina3b61d702016-09-20 06:49:52 -070021; RUN: %if --need=target_MIPS32 --need=allow_dump \
22; RUN: --command %p2i --filetype=asm --assemble \
Stefan Maksimovic0dabe182016-10-28 05:23:57 -070023; RUN: --disassemble --target mips32 -i %s --args -Om1 \
Srdjan Obucina3b61d702016-09-20 06:49:52 -070024; RUN: | %if --need=target_MIPS32 --need=allow_dump \
25; RUN: --command FileCheck --check-prefix MIPS32 %s
26
27; RUN: %if --need=target_MIPS32 --need=allow_dump \
28; RUN: --command %p2i --filetype=asm --assemble \
Stefan Maksimovic0dabe182016-10-28 05:23:57 -070029; RUN: --disassemble --target mips32 -i %s --args -O2 \
Srdjan Obucina3b61d702016-09-20 06:49:52 -070030; RUN: | %if --need=target_MIPS32 --need=allow_dump \
31; RUN: --command FileCheck --check-prefix MIPS32-O2 %s
32
Jim Stichnothf7c9a142014-04-29 10:52:43 -070033define internal i32 @divide(i32 %num, i32 %den) {
34entry:
35 %cmp = icmp ne i32 %den, 0
36 br i1 %cmp, label %return, label %abort
37
38abort: ; preds = %entry
39 unreachable
Jim Stichnothf7c9a142014-04-29 10:52:43 -070040
41return: ; preds = %entry
42 %div = sdiv i32 %num, %den
43 ret i32 %div
44}
45
Jan Voungdddc3062014-08-29 12:59:02 -070046; CHECK-LABEL: divide
Jim Stichnothd97c7df2014-06-04 11:57:08 -070047; CHECK: cmp
Jim Stichnothc53f7a62015-02-20 11:43:41 -080048; CHECK: ud2
Jim Stichnothd97c7df2014-06-04 11:57:08 -070049; CHECK: cdq
50; CHECK: idiv
51; CHECK: ret
Jan Voung6ec369e2015-06-30 11:03:15 -070052
53; ARM32-LABEL: divide
John Portoccea7932015-11-17 04:58:36 -080054; ARM32: tst
Jim Stichnoth533a5142016-10-06 14:24:38 -070055; ARM32: e7fedef0
John Portob82d79a2016-03-01 06:11:05 -080056; ARM32: bl {{.*}} __divsi3
Jan Voung6ec369e2015-06-30 11:03:15 -070057; ARM32: bx lr
Srdjan Obucina3b61d702016-09-20 06:49:52 -070058
59; MIPS32-LABEL: divide
60; MIPS32: beqz
61; MIPS32: nop
62; MIPS32: teq zero,zero
63; MIPS32: div
64
65; MIPS32-O2-LABEL: divide
66; MIPS32-O2: bne
67; MIPS32-O2: nop
68; MIPS32-O2: teq zero,zero
69; MIPS32-O2: div