[llvm-commits] [llvm] r90048 - /llvm/trunk/test/Transforms/GVN/pre-load.ll
Chris Lattner
sabre at nondot.org
Sat Nov 28 17:15:43 PST 2009
Author: lattner
Date: Sat Nov 28 19:15:43 2009
New Revision: 90048
URL: http://llvm.org/viewvc/llvm-project?rev=90048&view=rev
Log:
Add a testcase for:
void test(int N, double* G) {
long j;
for (j = 1; j < N - 1; j++)
G[j] = G[j] + G[j+1] + G[j-1];
}
which we now compile to one load in the loop:
LBB1_2: ## %bb
movsd 16(%rsi,%rax,8), %xmm2
incq %rdx
addsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movapd %xmm2, %xmm1
movsd %xmm0, 8(%rsi,%rax,8)
incq %rax
cmpq %rcx, %rax
jne LBB1_2
instead of:
LBB1_2: ## %bb
movsd 8(%rsi,%rax,8), %xmm0
addsd 16(%rsi,%rax,8), %xmm0
addsd (%rsi,%rax,8), %xmm0
movsd %xmm0, 8(%rsi,%rax,8)
incq %rax
cmpq %rcx, %rax
jne LBB1_2
Modified:
llvm/trunk/test/Transforms/GVN/pre-load.ll
Modified: llvm/trunk/test/Transforms/GVN/pre-load.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/pre-load.ll?rev=90048&r1=90047&r2=90048&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/GVN/pre-load.ll (original)
+++ llvm/trunk/test/Transforms/GVN/pre-load.ll Sat Nov 28 19:15:43 2009
@@ -314,3 +314,50 @@
ret void
}
+;void test10(int N, double* G) {
+; long j;
+; for (j = 1; j < N - 1; j++)
+; G[j] = G[j] + G[j+1] + G[j-1];
+;}
+
+define void @test10(i32 %N, double* nocapture %G) nounwind ssp {
+entry:
+ %0 = add i32 %N, -1
+ %1 = icmp sgt i32 %0, 1
+ br i1 %1, label %bb.nph, label %return
+
+bb.nph:
+ %tmp = sext i32 %0 to i64
+ %tmp8 = add i64 %tmp, -1
+ br label %bb
+; CHECK: bb.nph:
+; CHECK: load double*
+; CHECK: load double*
+; CHECK: br label %bb
+
+
+bb:
+ %indvar = phi i64 [ 0, %bb.nph ], [ %tmp11, %bb ]
+ %scevgep = getelementptr double* %G, i64 %indvar
+ %tmp9 = add i64 %indvar, 2
+ %scevgep10 = getelementptr double* %G, i64 %tmp9
+ %tmp11 = add i64 %indvar, 1
+ %scevgep12 = getelementptr double* %G, i64 %tmp11
+ %2 = load double* %scevgep12, align 8
+ %3 = load double* %scevgep10, align 8
+ %4 = fadd double %2, %3
+ %5 = load double* %scevgep, align 8
+ %6 = fadd double %4, %5
+ store double %6, double* %scevgep12, align 8
+ %exitcond = icmp eq i64 %tmp11, %tmp8
+ br i1 %exitcond, label %return, label %bb
+
+; Should only be one load in the loop.
+; CHECK: bb:
+; CHECK: load double*
+; CHECK-NOT: load double*
+; CHECK: br i1 %exitcond
+
+return:
+ ret void
+}
More information about the llvm-commits
mailing list