1; RUN: opt %loadPolly -polly-invariant-load-hoisting=true -polly-optree -analyze < %s | FileCheck %s -match-full-lines 2; 3; Move %val to %bodyB, so %bodyA can be removed (by -polly-simplify). 4; This involves making the load-hoisted %val1 to be made available in %bodyB. 5; 6; for (int j = 0; j < n; j += 1) { 7; bodyA: 8; double val = B[0] + 21.0; 9; 10; bodyB: 11; A[0] = val; 12; } 13; 14define void @func(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B) { 15entry: 16 br label %for 17 18for: 19 %j = phi i32 [0, %entry], [%j.inc, %inc] 20 %j.cmp = icmp slt i32 %j, %n 21 br i1 %j.cmp, label %bodyA, label %exit 22 23 bodyA: 24 %val1 = load double, double* %B 25 %val2 = fadd double %val1, 21.0 26 br label %bodyB 27 28 bodyB: 29 store double %val2, double* %A 30 br label %inc 31 32inc: 33 %j.inc = add nuw nsw i32 %j, 1 34 br label %for 35 36exit: 37 br label %return 38 39return: 40 ret void 41} 42 43 44; CHECK: Statistics { 45; CHECK: Instructions copied: 1 46; CHECK: Operand trees forwarded: 1 47; CHECK: Statements with forwarded operand trees: 1 48; CHECK: } 49 50; CHECK: After statements { 51; CHECK-NEXT: Stmt_bodyA 52; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 53; CHECK-NEXT: [n] -> { Stmt_bodyA[i0] -> MemRef_val2[] }; 54; CHECK-NEXT: Instructions { 55; CHECK-NEXT: %val1 = load double, double* %B, align 8 56; CHECK-NEXT: %val2 = fadd double %val1, 2.100000e+01 57; CHECK-NEXT: } 58; CHECK-NEXT: Stmt_bodyB 59; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 60; CHECK-NEXT: [n] -> { Stmt_bodyB[i0] -> MemRef_A[0] }; 61; CHECK-NEXT: Instructions { 62; CHECK-NEXT: %val2 = fadd double %val1, 2.100000e+01 63; CHECK-NEXT: store double %val2, double* %A, align 8 64; CHECK-NEXT: } 65; CHECK-NEXT: } 66