Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1 | ; This tests the basic structure of the Unreachable instruction. |
| 2 | |
Jan Voung | 6ec369e | 2015-06-30 11:03:15 -0700 | [diff] [blame] | 3 | ; 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 Stichnoth | 033dda7 | 2016-10-03 07:56:25 -0700 | [diff] [blame] | 10 | ; 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 Voung | 6ec369e | 2015-06-30 11:03:15 -0700 | [diff] [blame] | 14 | ; RUN: --command FileCheck --check-prefix ARM32 %s |
Jim Stichnoth | 033dda7 | 2016-10-03 07:56:25 -0700 | [diff] [blame] | 15 | ; 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 Voung | 70fa525 | 2015-07-06 14:01:25 -0700 | [diff] [blame] | 19 | ; RUN: --command FileCheck --check-prefix ARM32 %s |
Jan Voung | dddc306 | 2014-08-29 12:59:02 -0700 | [diff] [blame] | 20 | |
Srdjan Obucina | 3b61d70 | 2016-09-20 06:49:52 -0700 | [diff] [blame] | 21 | ; RUN: %if --need=target_MIPS32 --need=allow_dump \ |
| 22 | ; RUN: --command %p2i --filetype=asm --assemble \ |
Stefan Maksimovic | 0dabe18 | 2016-10-28 05:23:57 -0700 | [diff] [blame] | 23 | ; RUN: --disassemble --target mips32 -i %s --args -Om1 \ |
Srdjan Obucina | 3b61d70 | 2016-09-20 06:49:52 -0700 | [diff] [blame] | 24 | ; 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 Maksimovic | 0dabe18 | 2016-10-28 05:23:57 -0700 | [diff] [blame] | 29 | ; RUN: --disassemble --target mips32 -i %s --args -O2 \ |
Srdjan Obucina | 3b61d70 | 2016-09-20 06:49:52 -0700 | [diff] [blame] | 30 | ; RUN: | %if --need=target_MIPS32 --need=allow_dump \ |
| 31 | ; RUN: --command FileCheck --check-prefix MIPS32-O2 %s |
| 32 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 33 | define internal i32 @divide(i32 %num, i32 %den) { |
| 34 | entry: |
| 35 | %cmp = icmp ne i32 %den, 0 |
| 36 | br i1 %cmp, label %return, label %abort |
| 37 | |
| 38 | abort: ; preds = %entry |
| 39 | unreachable |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 40 | |
| 41 | return: ; preds = %entry |
| 42 | %div = sdiv i32 %num, %den |
| 43 | ret i32 %div |
| 44 | } |
| 45 | |
Jan Voung | dddc306 | 2014-08-29 12:59:02 -0700 | [diff] [blame] | 46 | ; CHECK-LABEL: divide |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 47 | ; CHECK: cmp |
Jim Stichnoth | c53f7a6 | 2015-02-20 11:43:41 -0800 | [diff] [blame] | 48 | ; CHECK: ud2 |
Jim Stichnoth | d97c7df | 2014-06-04 11:57:08 -0700 | [diff] [blame] | 49 | ; CHECK: cdq |
| 50 | ; CHECK: idiv |
| 51 | ; CHECK: ret |
Jan Voung | 6ec369e | 2015-06-30 11:03:15 -0700 | [diff] [blame] | 52 | |
| 53 | ; ARM32-LABEL: divide |
John Porto | ccea793 | 2015-11-17 04:58:36 -0800 | [diff] [blame] | 54 | ; ARM32: tst |
Jim Stichnoth | 533a514 | 2016-10-06 14:24:38 -0700 | [diff] [blame] | 55 | ; ARM32: e7fedef0 |
John Porto | b82d79a | 2016-03-01 06:11:05 -0800 | [diff] [blame] | 56 | ; ARM32: bl {{.*}} __divsi3 |
Jan Voung | 6ec369e | 2015-06-30 11:03:15 -0700 | [diff] [blame] | 57 | ; ARM32: bx lr |
Srdjan Obucina | 3b61d70 | 2016-09-20 06:49:52 -0700 | [diff] [blame] | 58 | |
| 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 |