brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · 9081359 Raw
82 lines · plain
1; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 \2; RUN:     -pass-remarks-output=%t -disable-output3; RUN: FileCheck -input-file %t --check-prefix=PROFIT-CACHE %s4 5; RUN: opt < %s -passes=loop-interchange -cache-line-size=64 \6; RUN:     -pass-remarks-output=%t -disable-output -loop-interchange-profitabilities=vectorize,cache,instorder7; RUN: FileCheck -input-file %t --check-prefix=PROFIT-VEC %s8 9@A = dso_local global [256 x [256 x float]] zeroinitializer10@B = dso_local global [256 x [256 x float]] zeroinitializer11@C = dso_local global [256 x [256 x float]] zeroinitializer12@D = dso_local global [256 x [256 x float]] zeroinitializer13@E = dso_local global [256 x [256 x float]] zeroinitializer14@F = dso_local global [256 x [256 x float]] zeroinitializer15 16; Check the behavior of the LoopInterchange cost-model. In the below code,17; exchanging the loops is not profitable in terms of cache, but it is necessary18; to vectorize the innermost loop.19;20; for (int i = 0; i < 256; i++)21;   for (int j = 1; j < 256; j++)22;     A[j][i] = A[j-1][i] + B[j][i] + C[i][j] + D[i][j] + E[i][j] + F[i][j];23;24 25; PROFIT-CACHE:      --- !Missed26; PROFIT-CACHE-NEXT: Pass:            loop-interchange27; PROFIT-CACHE-NEXT: Name:            InterchangeNotProfitable28; PROFIT-CACHE-NEXT: Function:        f29; PROFIT-CACHE-NEXT: Args:30; PROFIT-CACHE-NEXT:   - String:          Interchanging loops is not considered to improve cache locality nor vectorization.31; PROFIT-CACHE-NEXT: ...32 33; PROFIT-VEC:      --- !Passed34; PROFIT-VEC-NEXT: Pass:            loop-interchange35; PROFIT-VEC-NEXT: Name:            Interchanged36; PROFIT-VEC-NEXT: Function:        f37; PROFIT-VEC-NEXT: Args:38; PROFIT-VEC-NEXT:   - String:          Loop interchanged with enclosing loop.39; PROFIT-VEC-NEXT: ...40define void @f() {41entry:42  br label %for.i.header43 44for.i.header:45  %i = phi i64 [ 0, %entry ], [ %i.next, %for.i.inc ]46  br label %for.j.body47 48for.j.body:49  %j = phi i64 [ 1, %for.i.header ], [ %j.next, %for.j.body ]50  %j.dec = add nsw i64 %j, -151  %a.0.index = getelementptr nuw inbounds [256 x [256 x float]], ptr @A, i64 0, i64 %j.dec, i64 %i52  %b.index = getelementptr nuw inbounds [256 x [256 x float]], ptr @B, i64 0, i64 %j, i64 %i53  %c.index = getelementptr nuw inbounds [256 x [256 x float]], ptr @C, i64 0, i64 %i, i64 %j54  %d.index = getelementptr nuw inbounds [256 x [256 x float]], ptr @D, i64 0, i64 %i, i64 %j55  %e.index = getelementptr nuw inbounds [256 x [256 x float]], ptr @E, i64 0, i64 %i, i64 %j56  %f.index = getelementptr nuw inbounds [256 x [256 x float]], ptr @F, i64 0, i64 %i, i64 %j57  %a.0 = load float, ptr %a.0.index, align 458  %b = load float, ptr %b.index, align 459  %c = load float, ptr %c.index, align 460  %d = load float, ptr %d.index, align 461  %e = load float, ptr %e.index, align 462  %f = load float, ptr %f.index, align 463  %add.0 = fadd float %a.0, %b64  %add.1 = fadd float %add.0, %c65  %add.2 = fadd float %add.1, %d66  %add.3 = fadd float %add.2, %e67  %add.4 = fadd float %add.3, %f68  %a.1.index = getelementptr nuw inbounds [256 x float], ptr @A, i64 %j, i64 %i69  store float %add.4, ptr %a.1.index, align 470  %j.next = add nuw nsw i64 %j, 171  %cmp.j = icmp eq i64 %j.next, 25672  br i1 %cmp.j, label %for.i.inc, label %for.j.body73 74for.i.inc:75  %i.next = add nuw nsw i64 %i, 176  %cmp.i = icmp eq i64 %i.next, 25677  br i1 %cmp.i, label %exit, label %for.i.header78 79exit:80  ret void81}82