1 ; RUN: opt -S < %s -loop-rotate -licm -verify-dom-info -verify-loop-info | FileCheck %s
2 ; PR2624 unroll multiple exits
4 @mode_table = global [4 x i32] zeroinitializer ; <[4 x i32]*> [#uses=1]
10 tail call i32 @fegetround( ) ; <i32>:0 [#uses=1]
13 bb: ; preds = %bb4, %entry
14 %mode.0 = phi i8 [ 0, %entry ], [ %indvar.next, %bb4 ] ; <i8> [#uses=4]
15 zext i8 %mode.0 to i32 ; <i32>:1 [#uses=1]
16 getelementptr [4 x i32], [4 x i32]* @mode_table, i32 0, i32 %1 ; <i32*>:2 [#uses=1]
17 load i32, i32* %2, align 4 ; <i32>:3 [#uses=1]
18 icmp eq i32 %3, %0 ; <i1>:4 [#uses=1]
19 br i1 %4, label %bb1, label %bb2
25 icmp eq i8 %mode.0, 1 ; <i1>:5 [#uses=1]
26 br i1 %5, label %bb5, label %bb4
29 %indvar.next = add i8 %mode.0, 1 ; <i8> [#uses=1]
33 tail call void @raise_exception( ) noreturn
37 declare i32 @fegetround()
39 declare void @raise_exception() noreturn
41 ;CHECK: for.body.lr.ph:
42 ;CHECK-NEXT: %arrayidx1 = getelementptr inbounds i8, i8* %CurPtr, i64 0
43 ;CHECK-NEXT: %0 = load i8, i8* %arrayidx1, align 1
44 ;CHECK-NEXT: %conv2 = sext i8 %0 to i32
45 ;CHECK-NEXT: br label %for.body
47 define i32 @foo(i8* %CurPtr, i32 %a) #0 {
51 for.cond: ; preds = %for.inc, %entry
52 %i.0 = phi i32 [ 1, %entry ], [ %inc, %for.inc ]
53 %cmp = icmp ne i32 %i.0, %a
54 br i1 %cmp, label %for.body, label %return
56 for.body: ; preds = %for.cond
57 %idxprom = zext i32 %i.0 to i64
58 %arrayidx = getelementptr inbounds i8, i8* %CurPtr, i64 %idxprom
59 %0 = load i8, i8* %arrayidx, align 1
60 %conv = sext i8 %0 to i32
61 %arrayidx1 = getelementptr inbounds i8, i8* %CurPtr, i64 0
62 %1 = load i8, i8* %arrayidx1, align 1
63 %conv2 = sext i8 %1 to i32
64 %cmp3 = icmp ne i32 %conv, %conv2
65 br i1 %cmp3, label %return, label %for.inc
67 for.inc: ; preds = %for.body
68 %inc = add i32 %i.0, 1
71 return: ; preds = %for.cond, %for.body
72 %retval.0 = phi i32 [ 0, %for.body ], [ 1, %for.cond ]
76 attributes #0 = { nounwind uwtable }