diff options
author | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2015-11-03 16:49:02 +0000 |
---|---|---|
committer | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2015-11-03 16:49:02 +0000 |
commit | 475d8e3f4205111fbcb6a231684e59f5711b1415 (patch) | |
tree | 8162d0245544137b2334812836c5a1fe21470187 | |
parent | d6fc0701eeee301463f2d7cfa8d1bbb3a5f5db47 (diff) | |
download | bcm5719-llvm-475d8e3f4205111fbcb6a231684e59f5711b1415.tar.gz bcm5719-llvm-475d8e3f4205111fbcb6a231684e59f5711b1415.zip |
[FIX] Ensure base pointer origin was preloaded already
If a base pointer of a preloaded value has a base pointer origin, thus it is
an indirect invariant load, we have to make sure the base pointer origin is
preloaded first.
llvm-svn: 251946
-rw-r--r-- | polly/lib/CodeGen/IslNodeBuilder.cpp | 14 | ||||
-rw-r--r-- | polly/test/Isl/CodeGen/invariant-load-preload-base-pointer-origin-first.ll | 91 |
2 files changed, 104 insertions, 1 deletions
diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp index 439367b7aa0..930302a114f 100644 --- a/polly/lib/CodeGen/IslNodeBuilder.cpp +++ b/polly/lib/CodeGen/IslNodeBuilder.cpp @@ -938,6 +938,19 @@ void IslNodeBuilder::preloadInvariantEquivClass( if (ValueMap.count(MA->getAccessInstruction())) return; + // If the base pointer of this class is dependent on another one we have to + // make sure it was preloaded already. + auto *SAI = S.getScopArrayInfo(MA->getBaseAddr()); + if (auto *BasePtrOriginSAI = SAI->getBasePtrOriginSAI()) { + auto *BasePtrOriginBasePtr = BasePtrOriginSAI->getBasePtr(); + auto *BasePtrOriginBasePtrSCEV = SE.getSCEV(BasePtrOriginBasePtr); + + const auto &InvariantEquivClasses = S.getInvariantAccesses(); + for (const auto &OtherIAClass : InvariantEquivClasses) + if (std::get<0>(OtherIAClass) == BasePtrOriginBasePtrSCEV) + preloadInvariantEquivClass(OtherIAClass); + } + Instruction *AccInst = MA->getAccessInstruction(); Type *AccInstTy = AccInst->getType(); @@ -957,7 +970,6 @@ void IslNodeBuilder::preloadInvariantEquivClass( isl_id_free(ParamId); } - auto *SAI = S.getScopArrayInfo(MA->getBaseAddr()); for (auto *DerivedSAI : SAI->getDerivedSAIs()) { Value *BasePtr = DerivedSAI->getBasePtr(); diff --git a/polly/test/Isl/CodeGen/invariant-load-preload-base-pointer-origin-first.ll b/polly/test/Isl/CodeGen/invariant-load-preload-base-pointer-origin-first.ll new file mode 100644 index 00000000000..38275f4153d --- /dev/null +++ b/polly/test/Isl/CodeGen/invariant-load-preload-base-pointer-origin-first.ll @@ -0,0 +1,91 @@ +; RUN: opt %loadPolly -S -polly-codegen < %s +; +; Check that we generate valid code as we did non preload the base pointer +; origin of %tmp4 at some point. +; +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +@TOP = external global i64*, align 8 +@BOT = external global i64*, align 8 + +define void @RemoveConstraintVCG() { +entry: + br i1 undef, label %for.end.161, label %for.cond.2.preheader + +for.cond.2.preheader: ; preds = %entry + br i1 undef, label %for.end.128, label %for.body.4 + +for.body.4: ; preds = %for.inc.126, %for.cond.2.preheader + br i1 undef, label %for.cond.8.preheader, label %for.inc.126 + +for.cond.8.preheader: ; preds = %for.body.4 + br i1 undef, label %for.inc.126, label %for.body.11 + +for.body.11: ; preds = %for.inc, %for.cond.8.preheader + br i1 undef, label %land.lhs.true, label %for.inc + +land.lhs.true: ; preds = %for.body.11 + br i1 undef, label %if.then.20, label %for.inc + +if.then.20: ; preds = %land.lhs.true + %tmp = load i64*, i64** @TOP, align 8 + %tmp1 = load i64, i64* %tmp, align 8 + %cmp25 = icmp eq i64 %tmp1, 1 + %cmp47 = icmp eq i64 %tmp1, 0 + br i1 false, label %if.end.117, label %lor.lhs.false.85 + +lor.lhs.false.85: ; preds = %if.then.20 + %add94 = add i64 %tmp1, 1 + %tmp2 = load i64*, i64** @TOP, align 8 + %arrayidx95 = getelementptr inbounds i64, i64* %tmp2, i64 %add94 + %tmp3 = load i64, i64* %arrayidx95, align 8 + br i1 false, label %if.else.103, label %land.lhs.true.97 + +land.lhs.true.97: ; preds = %lor.lhs.false.85 + %tmp4 = load i64*, i64** @BOT, align 8 + %arrayidx99 = getelementptr inbounds i64, i64* %tmp4, i64 %add94 + %tmp5 = load i64, i64* %arrayidx99, align 8 + %tobool100 = icmp eq i64 %tmp5, 0 + br i1 %tobool100, label %if.else.103, label %if.then.101 + +if.then.101: ; preds = %land.lhs.true.97 + br label %if.end.117 + +if.else.103: ; preds = %land.lhs.true.97, %lor.lhs.false.85 + %tmp6 = load i64*, i64** @TOP, align 8 + %arrayidx105 = getelementptr inbounds i64, i64* %tmp6, i64 %add94 + %tmp7 = load i64, i64* %arrayidx105, align 8 + br i1 false, label %lor.lhs.false.107, label %if.else.112 + +lor.lhs.false.107: ; preds = %if.else.103 + %tmp8 = load i64*, i64** @BOT, align 8 + %arrayidx109 = getelementptr inbounds i64, i64* %tmp8, i64 %add94 + br i1 false, label %if.end.117, label %if.else.112 + +if.else.112: ; preds = %lor.lhs.false.107, %if.else.103 + br label %if.end.117 + +if.end.117: ; preds = %if.else.112, %lor.lhs.false.107, %if.then.101, %if.then.20 + br i1 undef, label %if.then.119, label %for.inc + +if.then.119: ; preds = %if.end.117 + br label %for.inc + +for.inc: ; preds = %if.then.119, %if.end.117, %land.lhs.true, %for.body.11 + br i1 false, label %for.body.11, label %for.inc.126 + +for.inc.126: ; preds = %for.inc, %for.cond.8.preheader, %for.body.4 + br i1 undef, label %for.end.128, label %for.body.4 + +for.end.128: ; preds = %for.inc.126, %for.cond.2.preheader + br i1 false, label %cond.false, label %cond.end + +cond.false: ; preds = %for.end.128 + unreachable + +cond.end: ; preds = %for.end.128 + unreachable + +for.end.161: ; preds = %entry + ret void +} |