Index: lib/Transform/ForwardOpTree.cpp =================================================================== --- lib/Transform/ForwardOpTree.cpp +++ lib/Transform/ForwardOpTree.cpp @@ -420,7 +420,7 @@ // do not add another MemoryAccess. MemoryAccess *Access = TargetStmt->getArrayAccessOrNULLFor(LI); if (Access && !DoIt) - return FD_CanForwardLeaf; + return FD_CanForwardTree; if (DoIt) TargetStmt->prependInstruction(LI); Index: test/ForwardOpTree/forward_into_region_redundant_use.ll =================================================================== --- /dev/null +++ test/ForwardOpTree/forward_into_region_redundant_use.ll @@ -0,0 +1,57 @@ +; RUN: opt %loadPolly -polly-invariant-load-hoisting=true -polly-optree -analyze < %s | FileCheck %s -match-full-lines +; + +define void @foo(float* %A, i32 %p, float* %B) { +start: + br label %branch + +branch: + %cmp = icmp eq i32 %p, 1024 + br i1 %cmp, label %next, label %end + +next: + %val = load float, float* %A + %fcmp = fcmp oeq float %val, 41.0 + br label %nonaffine + +nonaffine: + br i1 %fcmp, label %a, label %b + +a: + store float %val, float* %A + br label %end + +b: + store float 1.0, float* %A + br label %end + +end: + ret void +} + +; CHECK: After statements { +; CHECK-NEXT: Stmt_next +; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] +; CHECK-NEXT: [p] -> { Stmt_next[] -> MemRef_A[0] }; +; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] +; CHECK-NEXT: [p] -> { Stmt_next[] -> MemRef_fcmp[] }; +; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] +; CHECK-NEXT: [p] -> { Stmt_next[] -> MemRef_val[] }; +; CHECK-NEXT: Instructions { +; CHECK-NEXT: %val = load float, float* %A +; CHECK-NEXT: %fcmp = fcmp oeq float %val, 4.100000e+01 +; CHECK-NEXT: } +; CHECK-NEXT: Stmt_nonaffine__TO__end +; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] +; CHECK-NEXT: null; +; CHECK-NEXT: new: [p] -> { Stmt_nonaffine__TO__end[] -> MemRef_A[0] }; +; CHECK-NEXT: MayWriteAccess := [Reduction Type: NONE] [Scalar: 0] +; CHECK-NEXT: [p] -> { Stmt_nonaffine__TO__end[] -> MemRef_A[0] }; +; CHECK-NEXT: MayWriteAccess := [Reduction Type: NONE] [Scalar: 0] +; CHECK-NEXT: [p] -> { Stmt_nonaffine__TO__end[] -> MemRef_A[0] }; +; CHECK-NEXT: Instructions { +; CHECK-NEXT: %val = load float, float* %A +; CHECK-NEXT: %val = load float, float* %A +; CHECK-NEXT: %fcmp = fcmp oeq float %val, 4.100000e+01 +; CHECK-NEXT: } +; CHECK-NEXT: } Index: test/ForwardOpTree/forward_load_tripleuse.ll =================================================================== --- test/ForwardOpTree/forward_load_tripleuse.ll +++ test/ForwardOpTree/forward_load_tripleuse.ll @@ -125,8 +125,8 @@ ; CHECK: Statistics { ; CHECK: Instructions copied: 1 -; CHECK: Known loads forwarded: 2 -; CHECK: Operand trees forwarded: 1 +; CHECK: Known loads forwarded: 3 +; CHECK: Operand trees forwarded: 2 ; CHECK: Statements with forwarded operand trees: 1 ; CHECK: } @@ -150,11 +150,10 @@ ; CHECK-NEXT: [n] -> { Stmt_bodyB[i0] -> MemRef_B[i0] }; ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] ; CHECK-NEXT: [n] -> { Stmt_bodyB[i0] -> MemRef_C[i0] }; -; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] -; CHECK-NEXT: [n] -> { Stmt_bodyB[i0] -> MemRef_val1[] }; ; CHECK-NEXT: Instructions { ; CHECK-NEXT: %val1 = load double, double* %A_idx ; CHECK-NEXT: %val1 = load double, double* %A_idx +; CHECK-NEXT: %val1 = load double, double* %A_idx ; CHECK-NEXT: %val2 = fadd double %val1, %val1 ; CHECK-NEXT: store double %val2, double* %B_idx ; CHECK-NEXT: store double %val1, double* %C_idx