1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -indvars -S < %s | FileCheck %s
3
4; Check the case where one exit has a pointer EC, and the other doesn't.
5; Note that this test case is really really fragile.  Removing any
6; instruction in the below causes the result to differ.  Note that the lack
7; of a data layout (with pointer size info) is critical to getting a pointer
8; EC returned by SCEV.
9
10@global = external global [0 x i8], align 1
11
12define void @foo() {
13; CHECK-LABEL: @foo(
14; CHECK-NEXT:  bb:
15; CHECK-NEXT:    br label [[BB3:%.*]]
16; CHECK:       bb3:
17; CHECK-NEXT:    [[TMP:%.*]] = phi i8* [ [[TMP4:%.*]], [[BB7:%.*]] ], [ getelementptr inbounds ([0 x i8], [0 x i8]* @global, i64 0, i64 2), [[BB:%.*]] ]
18; CHECK-NEXT:    [[TMP4]] = getelementptr inbounds i8, i8* [[TMP]], i64 -1
19; CHECK-NEXT:    [[TMP6:%.*]] = load i8, i8* [[TMP4]], align 1
20; CHECK-NEXT:    [[TMP5:%.*]] = icmp ugt i8* [[TMP4]], getelementptr inbounds ([0 x i8], [0 x i8]* @global, i64 0, i64 500)
21; CHECK-NEXT:    br i1 [[TMP5]], label [[BB7]], label [[BB11:%.*]]
22; CHECK:       bb7:
23; CHECK-NEXT:    [[TMP8:%.*]] = zext i8 [[TMP6]] to i64
24; CHECK-NEXT:    br i1 true, label [[BB11]], label [[BB3]]
25; CHECK:       bb11:
26; CHECK-NEXT:    ret void
27;
28bb:
29  br label %bb3
30
31bb3:                                              ; preds = %bb7, %bb2
32  %tmp = phi i8* [ %tmp4, %bb7 ], [ getelementptr inbounds ([0 x i8], [0 x i8]* @global, i64 0, i64 2), %bb ]
33  %tmp4 = getelementptr inbounds i8, i8* %tmp, i64 -1
34  %tmp6 = load i8, i8* %tmp4, align 1
35  %tmp5 = icmp ugt i8* %tmp4, getelementptr inbounds ([0 x i8], [0 x i8]* @global, i64 0, i64 500)
36  br i1 %tmp5, label %bb7, label %bb11
37
38bb7:                                              ; preds = %bb3
39  %tmp8 = zext i8 %tmp6 to i64
40  %tmp10 = icmp eq i16 0, 0
41  br i1 %tmp10, label %bb11, label %bb3
42
43bb11:                                             ; preds = %bb7, %bb3
44  ret void
45}
46