Jan Wen Voung | 6dc3076 | 2013-03-12 16:27:52 +0000 | [diff] [blame] | 1 | ; REQUIRES: asserts |
Dan Gohman | 0ad7d9c | 2010-09-01 21:46:45 +0000 | [diff] [blame] | 2 | ; RUN: opt -loop-unswitch -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s |
| 3 | ; RUN: opt -loop-unswitch -simplifycfg -S < %s | FileCheck %s |
| 4 | ; PR5373 |
| 5 | |
| 6 | ; Loop unswitching shouldn't trivially unswitch the true case of condition %a |
| 7 | ; in the code here because it leads to an infinite loop. While this doesn't |
| 8 | ; contain any instructions with side effects, it's still a kind of side effect. |
| 9 | ; It can trivially unswitch on the false cas of condition %a though. |
| 10 | |
| 11 | ; STATS: 2 loop-unswitch - Number of branches unswitched |
| 12 | ; STATS: 1 loop-unswitch - Number of unswitches that are trivial |
| 13 | |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame^] | 14 | ; CHECK-LABEL: @func_16( |
Dan Gohman | 0ad7d9c | 2010-09-01 21:46:45 +0000 | [diff] [blame] | 15 | ; CHECK-NEXT: entry: |
| 16 | ; CHECK-NEXT: br i1 %a, label %entry.split, label %abort0.split |
| 17 | |
| 18 | ; CHECK: entry.split: |
| 19 | ; CHECK-NEXT: br i1 %b, label %cond.end.us, label %abort1 |
| 20 | |
| 21 | ; CHECK: cond.end.us: |
| 22 | ; CHECK-NEXT: br label %cond.end.us |
| 23 | |
| 24 | ; CHECK: abort0.split: |
Bill Wendling | a032374 | 2013-02-22 09:09:42 +0000 | [diff] [blame] | 25 | ; CHECK-NEXT: call void @end0() [[NOR_NUW:#[0-9]+]] |
Dan Gohman | 0ad7d9c | 2010-09-01 21:46:45 +0000 | [diff] [blame] | 26 | ; CHECK-NEXT: unreachable |
| 27 | |
| 28 | ; CHECK: abort1: |
Bill Wendling | a032374 | 2013-02-22 09:09:42 +0000 | [diff] [blame] | 29 | ; CHECK-NEXT: call void @end1() [[NOR_NUW]] |
Dan Gohman | 0ad7d9c | 2010-09-01 21:46:45 +0000 | [diff] [blame] | 30 | ; CHECK-NEXT: unreachable |
| 31 | |
| 32 | ; CHECK: } |
| 33 | |
| 34 | define void @func_16(i1 %a, i1 %b) nounwind { |
| 35 | entry: |
| 36 | br label %for.body |
| 37 | |
| 38 | for.body: |
| 39 | br i1 %a, label %cond.end, label %abort0 |
| 40 | |
| 41 | cond.end: |
| 42 | br i1 %b, label %for.body, label %abort1 |
| 43 | |
| 44 | abort0: |
| 45 | call void @end0() noreturn nounwind |
| 46 | unreachable |
| 47 | |
| 48 | abort1: |
| 49 | call void @end1() noreturn nounwind |
| 50 | unreachable |
| 51 | } |
| 52 | |
| 53 | declare void @end0() noreturn |
| 54 | declare void @end1() noreturn |
Bill Wendling | a032374 | 2013-02-22 09:09:42 +0000 | [diff] [blame] | 55 | |
| 56 | ; CHECK: attributes #0 = { nounwind } |
| 57 | ; CHECK: attributes #1 = { noreturn } |
| 58 | ; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind } |