blob: 91e1f486b8286bd812290d7842f4c9a402a70400 [file] [log] [blame]
Eric Christophercee313d2019-04-17 04:52:47 +00001; REQUIRES: asserts
2; RUN: opt -simple-loop-unswitch -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s
3; RUN: opt -simple-loop-unswitch -S < %s | FileCheck %s
4; RUN: opt -simple-loop-unswitch -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s
5; PR5373
6
7; Loop unswitching shouldn't trivially unswitch the true case of condition %a
8; in the code here because it leads to an infinite loop. While this doesn't
9; contain any instructions with side effects, it's still a kind of side effect.
10; It can trivially unswitch on the false cas of condition %a though.
11
12; STATS: 2 simple-loop-unswitch - Number of branches unswitched
13; STATS: 2 simple-loop-unswitch - Number of unswitches that are trivial
14
15; CHECK-LABEL: @func_16(
16; CHECK-NEXT: entry:
17; CHECK-NEXT: br i1 %a, label %entry.split, label %abort0
18
19; CHECK: entry.split:
20; CHECK-NEXT: br i1 %b, label %entry.split.split, label %abort1
21
22; CHECK: entry.split.split:
23; CHECK-NEXT: br label %for.body
24
25; CHECK: for.body:
26; CHECK-NEXT: br label %cond.end
27
28; CHECK: cond.end:
29; CHECK-NEXT: br label %for.body
30
31; CHECK: abort0:
32; CHECK-NEXT: call void @end0() [[NOR_NUW:#[0-9]+]]
33; CHECK-NEXT: unreachable
34
35; CHECK: abort1:
36; CHECK-NEXT: call void @end1() [[NOR_NUW]]
37; CHECK-NEXT: unreachable
38
39; CHECK: }
40
41define void @func_16(i1 %a, i1 %b) nounwind {
42entry:
43 br label %for.body
44
45for.body:
46 br i1 %a, label %cond.end, label %abort0
47
48cond.end:
49 br i1 %b, label %for.body, label %abort1
50
51abort0:
52 call void @end0() noreturn nounwind
53 unreachable
54
55abort1:
56 call void @end1() noreturn nounwind
57 unreachable
58}
59
60declare void @end0() noreturn
61declare void @end1() noreturn
62
63; CHECK: attributes #0 = { nounwind }
64; CHECK: attributes #1 = { noreturn }
65; CHECK: attributes [[NOR_NUW]] = { noreturn nounwind }