Is there a transformation in LLVM that will perform loop fusion? http://en.wikipedia.org/wiki/Loop_fusion I have the following program, in which I would like the 2 loops (iterating the same number of times) to be merged into 1, after which other nice optimizations such as mem2reg will apply: ; ModuleID = 'test' define void @vector([16 x float]* nocapture %arg, [16 x float]* nocapture %ret) { bb.nph12: %0 = alloca [16 x float], align 4 ; <[16 x float]*> [#uses=2] br label %loop loop: ; preds = %loop, %bb.nph12 %indvar13 = phi i64 [ 0, %bb.nph12 ], [ %indvar.next14, %loop ] ; <i64> [#uses=3] %gep = getelementptr [16 x float]* %ret, i64 0, i64 %indvar13 ; <float*> [#uses=1] %gep1 = getelementptr [16 x float]* %0, i64 0, i64 %indvar13 ; <float*> [#uses=1] %load = load float* %gep ; <float> [#uses=1] store float %load, float* %gep1 %indvar.next14 = add i64 %indvar13, 1 ; <i64> [#uses=2] %exitcond15 = icmp eq i64 %indvar.next14, 16 ; <i1> [#uses=1] br i1 %exitcond15, label %loop3, label %loop loop3: ; preds = %loop, %loop3 %indvar = phi i64 [ %indvar.next, %loop3 ], [ 0, %loop ] ; <i64> [#uses=3] %gep6 = getelementptr [16 x float]* %0, i64 0, i64 %indvar ; <float*> [#uses=1] %gep8 = getelementptr [16 x float]* %arg, i64 0, i64 %indvar ; <float*> [#uses=1] %load7 = load float* %gep6 ; <float> [#uses=1] store float %load7, float* %gep8 %indvar.next = add i64 %indvar, 1 ; <i64> [#uses=2] %exitcond = icmp eq i64 %indvar.next, 16 ; <i1> [#uses=1] br i1 %exitcond, label %end4, label %loop3 end4: ; preds = %loop3 ret void }