1; RUN: opt %loadPolly -polly-optree-normalize-phi=true -polly-optree -analyze < %s | FileCheck %s -match-full-lines 2; 3; Rematerialize a load. 4; 5; for (int j = 0; j < n; j += 1) { 6; bodyA: 7; double val = B[j]; 8; 9; bodyB: 10; double phi = val; 11; 12; bodyC: 13; A[j] = phi; 14; } 15; 16define void @func(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B) { 17entry: 18 br label %for 19 20for: 21 %j = phi i32 [0, %entry], [%j.inc, %inc] 22 %j.cmp = icmp slt i32 %j, %n 23 br i1 %j.cmp, label %bodyA, label %exit 24 25 bodyA: 26 %B_idx = getelementptr inbounds double, double* %B, i32 %j 27 %val = load double, double* %B_idx 28 br label %bodyB 29 30 bodyB: 31 %phi = phi double [%val, %bodyA] 32 br label %bodyC 33 34 bodyC: 35 %A_idx = getelementptr inbounds double, double* %A, i32 %j 36 store double %phi, double* %A_idx 37 br label %inc 38 39inc: 40 %j.inc = add nuw nsw i32 %j, 1 41 br label %for 42 43exit: 44 br label %return 45 46return: 47 ret void 48} 49 50 51; CHECK: Statistics { 52; CHECK: Reloads: 2 53; CHECK: } 54 55; CHECK-NEXT: After statements { 56; CHECK-NEXT: Stmt_bodyA 57; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 58; CHECK-NEXT: [n] -> { Stmt_bodyA[i0] -> MemRef_B[i0] }; 59; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 60; CHECK-NEXT: [n] -> { Stmt_bodyA[i0] -> MemRef_phi__phi[] }; 61; CHECK-NEXT: Instructions { 62; CHECK-NEXT: %val = load double, double* %B_idx, align 8 63; CHECK-NEXT: } 64; CHECK-NEXT: Stmt_bodyB 65; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 66; CHECK-NEXT: [n] -> { Stmt_bodyB[i0] -> MemRef_phi__phi[] }; 67; CHECK-NEXT: new: [n] -> { Stmt_bodyB[i0] -> MemRef_B[i0] }; 68; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 69; CHECK-NEXT: [n] -> { Stmt_bodyB[i0] -> MemRef_phi[] }; 70; CHECK-NEXT: Instructions { 71; CHECK-NEXT: %phi = phi double [ %val, %bodyA ] 72; CHECK-NEXT: } 73; CHECK-NEXT: Stmt_bodyC 74; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 75; CHECK-NEXT: [n] -> { Stmt_bodyC[i0] -> MemRef_A[i0] }; 76; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 77; CHECK-NEXT: [n] -> { Stmt_bodyC[i0] -> MemRef_phi[] }; 78; CHECK-NEXT: new: [n] -> { Stmt_bodyC[i0] -> MemRef_B[i0] }; 79; CHECK-NEXT: Instructions { 80; CHECK-NEXT: store double %phi, double* %A_idx, align 8 81; CHECK-NEXT: } 82; CHECK-NEXT: } 83