Merging r257940:
[oota-llvm.git] / test / Transforms / IRCE / bug-mismatched-types.ll
1 ; RUN: opt -irce -S < %s
2
3 ; These test cases don't check the correctness of the transform, but
4 ; that the -irce does not crash in the presence of certain things in
5 ; the IR:
6
7 define void @mismatched_types_1() {
8 ; In this test case, the safe range for the only range check in the
9 ; loop is of type [i32, i32) while the backedge taken count is of type
10 ; i64.
11
12 ; CHECK-LABEL: mismatched_types_1
13 entry:
14   br label %for.body
15
16 for.body:
17   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.inc ]
18   %0 = trunc i64 %indvars.iv to i32
19   %1 = icmp ult i32 %0, 7
20   br i1 %1, label %switch.lookup, label %for.inc
21
22 switch.lookup:
23   br label %for.inc
24
25 for.inc:
26   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
27   %cmp55 = icmp slt i64 %indvars.iv.next, 11
28   br i1 %cmp55, label %for.body, label %for.end
29
30 for.end:
31   unreachable
32 }
33
34 define void @mismatched_types_2() {
35 ; In this test case, there are two range check in the loop, one with a
36 ; safe range of type [i32, i32) and one with a safe range of type
37 ; [i64, i64).
38
39 ; CHECK-LABEL: mismatched_types_2
40 entry:
41   br label %for.body.a
42
43 for.body.a:
44   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.inc ]
45   %cond.a = icmp ult i64 %indvars.iv, 7
46   br i1 %cond.a, label %switch.lookup.a, label %for.body.b
47
48 switch.lookup.a:
49   br label %for.body.b
50
51 for.body.b:
52   %truncated = trunc i64 %indvars.iv to i32
53   %cond.b = icmp ult i32 %truncated, 7
54   br i1 %cond.b, label %switch.lookup.b, label %for.inc
55
56 switch.lookup.b:
57   br label %for.inc
58
59 for.inc:
60   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
61   %cmp55 = icmp slt i64 %indvars.iv.next, 11
62   br i1 %cmp55, label %for.body.a, label %for.end
63
64 for.end:
65   unreachable
66 }