brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 5c64221 Raw
78 lines · plain
1; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb '-passes=polly-custom<optree>' -polly-print-optree -disable-output < %s | FileCheck %s -match-full-lines2;3; Forward a the LoadInst %val into %bodyB. %val is executed multiple times,4; we must get the last loaded values.5;6; for (int j = 0; j < n; j += 1) {7;   double val;8;   for (int i = 0; i < n; i += 1) {9; bodyA:10;     val = B[j];11;   }12;13; bodyB:14;   A[j] = val;15; }16;17define void @func(i32 %n, ptr noalias nonnull %A, ptr noalias nonnull %B) {18entry:19  br label %for20 21for:22  %j = phi i32 [0, %entry], [%j.inc, %inc]23  %j.cmp = icmp sle i32 %j, %n24  br i1 %j.cmp, label %bodyA, label %exit25 26    bodyA:27      %i = phi i32 [0, %for], [%i.inc, %bodyA]28      %B_idx = getelementptr inbounds double, ptr %B, i32 %i29      %val = load double, ptr %B_idx30      %i.inc = add nuw nsw i32 %i, 131      %i.cmp = icmp slt i32 %i, %n32      br i1 %i.cmp, label %bodyA, label %bodyB33 34    bodyB:35      %A_idx = getelementptr inbounds double, ptr %A, i32 %j36      store double %val, ptr %A_idx37      br label %inc38 39inc:40  %j.inc = add nuw nsw i32 %j, 141  br label %for42 43exit:44  br label %return45 46return:47  ret void48}49 50 51; CHECK: Statistics {52; CHECK:     Known loads forwarded: 153; CHECK:     Operand trees forwarded: 154; CHECK:     Statements with forwarded operand trees: 155; CHECK: }56 57; CHECK:      After statements {58; CHECK-NEXT:     Stmt_bodyA59; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]60; CHECK-NEXT:                 [n] -> { Stmt_bodyA[i0, i1] -> MemRef_B[i1] };61; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]62; CHECK-NEXT:                 [n] -> { Stmt_bodyA[i0, i1] -> MemRef_val[] };63; CHECK-NEXT:             Instructions {64; CHECK-NEXT:                   %val = load double, ptr %B_idx, align 865; CHECK-NEXT:                   %i.cmp = icmp slt i32 %i, %n66; CHECK-NEXT:             }67; CHECK-NEXT:     Stmt_bodyB68; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]69; CHECK-NEXT:                 ;70; CHECK-NEXT:            new: [n] -> { Stmt_bodyB[i0] -> MemRef_B[n] };71; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]72; CHECK-NEXT:                 [n] -> { Stmt_bodyB[i0] -> MemRef_A[i0] };73; CHECK-NEXT:             Instructions {74; CHECK-NEXT:                   %val = load double, ptr %B_idx, align 875; CHECK-NEXT:                   store double %val, ptr %A_idx, align 876; CHECK-NEXT:             }77; CHECK-NEXT: }78