1 ; RUN: opt -S -indvars < %s | FileCheck %s
3 ; Produced from the test-case:
5 ; extern void foo(char *, unsigned , unsigned *);
6 ; extern void bar(int *, long);
7 ; extern char *processBuf(char *);
9 ; extern unsigned theSize;
11 ; void foo(char *buf, unsigned denominator, unsigned *flag) {
12 ; int incr = (int) (theSize / denominator);
15 ; int itmp = inx + incr;
16 ; int i = (int) theSize;
17 ; bar(&i, (long) itmp);
18 ; buf = processBuf(buf);
23 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
25 @theSize = external local_unnamed_addr global i32, align 4
27 define void @foo(i8* %buf, i32 %denominator, i32* %flag) local_unnamed_addr {
29 %i = alloca i32, align 4
30 %0 = load i32, i32* @theSize, align 4
31 %div = udiv i32 %0, %denominator
32 %1 = load i32, i32* %flag, align 4
33 %tobool5 = icmp eq i32 %1, 0
34 br i1 %tobool5, label %while.end, label %while.body.lr.ph
36 while.body.lr.ph: ; preds = %entry
37 %2 = bitcast i32* %i to i8*
40 while.body: ; preds = %while.body.lr.ph, %while.body
41 ; Check that there are two PHIs followed by a 'sext' in the same block, and that
42 ; the test does not crash.
46 %buf.addr.07 = phi i8* [ %buf, %while.body.lr.ph ], [ %call, %while.body ]
47 %inx.06 = phi i32 [ 0, %while.body.lr.ph ], [ %add, %while.body ]
48 %add = add nsw i32 %inx.06, %div
49 %3 = load i32, i32* @theSize, align 4
50 store i32 %3, i32* %i, align 4
51 %conv = sext i32 %add to i64
52 call void @bar(i32* nonnull %i, i64 %conv)
53 %call = call i8* @processBuf(i8* %buf.addr.07)
54 %4 = load i32, i32* %flag, align 4
55 %tobool = icmp eq i32 %4, 0
56 br i1 %tobool, label %while.end.loopexit, label %while.body
58 while.end.loopexit: ; preds = %while.body
61 while.end: ; preds = %while.end.loopexit, %entry
65 declare void @bar(i32*, i64) local_unnamed_addr
66 declare i8* @processBuf(i8*) local_unnamed_addr