From b6c5a5dd01326e306b03b9661b60b391f3e559f3 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Thu, 1 Dec 2016 11:10:45 +0000 Subject: [PATCH] [FIX] Do not try to hoist obviously overwritten loads llvm-svn: 288328 --- polly/lib/Support/ScopHelper.cpp | 3 +++ polly/test/ScopInfo/partially_invariant_load_2.ll | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp index 899355e..71fc9e8 100644 --- a/polly/lib/Support/ScopHelper.cpp +++ b/polly/lib/Support/ScopHelper.cpp @@ -454,6 +454,9 @@ bool polly::isHoistableLoad(LoadInst *LInst, Region &R, LoopInfo &LI, continue; auto &BB = *UserI->getParent(); + if (DT.dominates(&BB, LInst->getParent())) + return false; + bool DominatesAllPredecessors = true; for (auto Pred : predecessors(R.getExit())) if (R.contains(Pred) && !DT.dominates(&BB, Pred)) diff --git a/polly/test/ScopInfo/partially_invariant_load_2.ll b/polly/test/ScopInfo/partially_invariant_load_2.ll index 4813650..4269c32 100644 --- a/polly/test/ScopInfo/partially_invariant_load_2.ll +++ b/polly/test/ScopInfo/partially_invariant_load_2.ll @@ -3,13 +3,14 @@ ; Check that we do not try to preload *I and assume p != 42. ; ; CHECK: Invariant Accesses: { -; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] -; CHECK-NEXT: [N, p, tmp1, q] -> { Stmt_if_then[i0] -> MemRef_I[0] }; -; CHECK-NEXT: Execution Context: [N, p, tmp1, q] -> { : 1 = 0 } ; CHECK-NEXT: } ; ; CHECK: Invalid Context: -; CHECK-NEXT: [N, p, tmp1, q] -> { : p = 42 and N > 0 } +; CHECK-NEXT: [N, p] -> { : 1 = 0 } +; +; CHECK: Stmt_if_then__TO__if_end +; CHECK-NEXT: Domain := +; CHECK-NEXT: [N, p] -> { Stmt_if_then__TO__if_end[i0] : p = 42 and 0 <= i0 < N }; ; ; void f(int *A, int *I, int N, int p, int q) { ; for (int i = 0; i < N; i++) { -- 2.7.4