• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S < %s -loop-rotate -licm -verify-dom-info -verify-loop-info | FileCheck %s
2; PR2624 unroll multiple exits
3
4@mode_table = global [4 x i32] zeroinitializer		; <[4 x i32]*> [#uses=1]
5
6; CHECK-LABEL: @f(
7; CHECK-NOT: bb:
8define i8 @f() {
9entry:
10	tail call i32 @fegetround( )		; <i32>:0 [#uses=1]
11	br label %bb
12
13bb:		; 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
20
21bb1:		; preds = %bb
22	ret i8 %mode.0
23
24bb2:		; preds = %bb
25	icmp eq i8 %mode.0, 1		; <i1>:5 [#uses=1]
26	br i1 %5, label %bb5, label %bb4
27
28bb4:		; preds = %bb2
29	%indvar.next = add i8 %mode.0, 1		; <i8> [#uses=1]
30	br label %bb
31
32bb5:		; preds = %bb2
33	tail call void @raise_exception( ) noreturn
34	unreachable
35}
36
37declare i32 @fegetround()
38
39declare void @raise_exception() noreturn
40
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
46
47define i32 @foo(i8* %CurPtr, i32 %a) #0 {
48entry:
49  br label %for.cond
50
51for.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
55
56for.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
66
67for.inc:					  ; preds = %for.body
68  %inc = add i32 %i.0, 1
69  br label %for.cond
70
71return:						  ; preds = %for.cond, %for.body
72  %retval.0 = phi i32 [ 0, %for.body ], [ 1, %for.cond ]
73  ret i32 %retval.0
74}
75
76attributes #0 = { nounwind uwtable }
77