1; This testcase comes from this C fragment:
2;
3; void test(unsigned Num, int *Array) {
4;  unsigned i, j, k;
5;
6;  for (i = 0; i != Num; ++i)
7;    for (j = 0; j != Num; ++j)
8;      for (k = 0; k != Num; ++k)
9;        printf("%d\n", i+k+j);    /* Reassociate to (i+j)+k */
10;}
11;
12; In this case, we want to reassociate the specified expr so that i+j can be
13; hoisted out of the inner most loop.
14;
15; RUN: opt < %s -reassociate -S | FileCheck %s
16; END.
17@.LC0 = internal global [4 x i8] c"%d\0A\00"		; <[4 x i8]*> [#uses=1]
18
19declare i32 @printf(i8*, ...)
20
21; Check that (i+j) has been reassociated (i=reg115, j=reg116)
22; CHECK: %reg113 = add i32 %reg116, %reg115
23define void @test(i32 %Num, i32* %Array) {
24bb0:
25	%cond221 = icmp eq i32 0, %Num		; <i1> [#uses=3]
26	br i1 %cond221, label %bb7, label %bb2
27bb2:		; preds = %bb6, %bb0
28	%reg115 = phi i32 [ %reg120, %bb6 ], [ 0, %bb0 ]		; <i32> [#uses=2]
29	br i1 %cond221, label %bb6, label %bb3
30bb3:		; preds = %bb5, %bb2
31	%reg116 = phi i32 [ %reg119, %bb5 ], [ 0, %bb2 ]		; <i32> [#uses=2]
32	br i1 %cond221, label %bb5, label %bb4
33bb4:		; preds = %bb4, %bb3
34	%reg117 = phi i32 [ %reg118, %bb4 ], [ 0, %bb3 ]		; <i32> [#uses=2]
35	%reg113 = add i32 %reg115, %reg117		; <i32> [#uses=1]
36	%reg114 = add i32 %reg113, %reg116		; <i32> [#uses=1]
37	%cast227 = getelementptr [4 x i8], [4 x i8]* @.LC0, i64 0, i64 0		; <i8*> [#uses=1]
38	call i32 (i8*, ...) @printf( i8* %cast227, i32 %reg114 )		; <i32>:0 [#uses=0]
39	%reg118 = add i32 %reg117, 1		; <i32> [#uses=2]
40	%cond224 = icmp ne i32 %reg118, %Num		; <i1> [#uses=1]
41	br i1 %cond224, label %bb4, label %bb5
42bb5:		; preds = %bb4, %bb3
43	%reg119 = add i32 %reg116, 1		; <i32> [#uses=2]
44	%cond225 = icmp ne i32 %reg119, %Num		; <i1> [#uses=1]
45	br i1 %cond225, label %bb3, label %bb6
46bb6:		; preds = %bb5, %bb2
47	%reg120 = add i32 %reg115, 1		; <i32> [#uses=2]
48	%cond226 = icmp ne i32 %reg120, %Num		; <i1> [#uses=1]
49	br i1 %cond226, label %bb2, label %bb7
50bb7:		; preds = %bb6, %bb0
51	ret void
52}
53