; RUN: llvm-upgrade < %s | llvm-as | opt  -licm -stats |& \
; RUN:   grep {memory locations promoted to register}

%X = global int 7

void %testfunc(int %i) {
	br label %Loop

Loop:
	%j = phi uint [0, %0], [%Next, %Loop]

	%x = load int* %X  ; Should promote this to a register inside of loop!
	%x2 = add int %x, 1
	store int %x2, int* %X

	%Next = add uint %j, 1
	%cond = seteq uint %Next, 0
	br bool %cond, label %Out, label %Loop

Out:
	ret void
}

void %testhard(int %i) {
	br label %Loop
Loop:
	%X1 = getelementptr int* %X, long 0
	%A = load int* %X1 ; Aliases X, needs to be rewritten
	%V = add int %A, 1
	%X2 = getelementptr int* %X, long 0
	store int %V, int* %X2
	br bool false, label %Loop, label %Exit

Exit:
	ret void

}

; RUN: llvm-upgrade < %s | llvm-as | opt  -licm -stats |& \
; RUN:    grep {memory locations promoted to register}

%X = global int 7

void %testfunc(int %i) {
	br label %Loop

Loop:
	%j = phi uint [0, %0], [%Next, %Loop]

	%x = load int* %X  ; Should promote this to a register inside of loop!
	%x2 = add int %x, 1
	store int %x2, int* %X

	%Next = add uint %j, 1
	%cond = seteq uint %Next, 0
	br bool %cond, label %Out, label %Loop

Out:
	ret void
}

void %testhard(int %i) {
	br label %Loop
Loop:
	%X1 = getelementptr int* %X, long 0
	%A = load int* %X1 ; Aliases X, needs to be rewritten
	%V = add int %A, 1
	%X2 = getelementptr int* %X, long 0
	store int %V, int* %X2
	br bool false, label %Loop, label %Exit

Exit:
	ret void

}

Fix this test from Duncan's experiment.
Fix this test from Duncan's experiment.


git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@36176 91177308-0d34-0410-b5e6-96231b3b80d8
