[FIX] Do not hoist nested variant base pointers
This fixes bug 25249. llvm-svn: 250958
This commit is contained in:
parent
86713d90c7
commit
654c3284f4
|
@ -2549,14 +2549,18 @@ void Scop::hoistInvariantLoads() {
|
|||
// not loaded inside the SCoP. This can happened e.g., if a readnone call
|
||||
// returns a pointer that is used as a base address. However, as we want
|
||||
// to hoist indirect pointers, we allow the base pointer to be defined in
|
||||
// the region if it is also a memory access. Hence, if the ScopArrayInfo
|
||||
// object has a base pointer origin we know the base pointer is loaded and
|
||||
// that it is invariant, thus it will be hoisted too.
|
||||
// the region if it is also a memory access. Each ScopArrayInfo object
|
||||
// that has a base pointer origin has a base pointer that is loaded and
|
||||
// that it is invariant, thus it will be hoisted too. However, if there is
|
||||
// no bease pointer origin we check that the base pointer is defined
|
||||
// outside the region.
|
||||
const ScopArrayInfo *SAI = MA->getScopArrayInfo();
|
||||
if (!SAI->getBasePtrOriginSAI())
|
||||
if (auto *BasePtrInst = dyn_cast<Instruction>(SAI->getBasePtr()))
|
||||
if (R.contains(BasePtrInst))
|
||||
continue;
|
||||
while (auto *BasePtrOriginSAI = SAI->getBasePtrOriginSAI())
|
||||
SAI = BasePtrOriginSAI;
|
||||
|
||||
if (auto *BasePtrInst = dyn_cast<Instruction>(SAI->getBasePtr()))
|
||||
if (R.contains(BasePtrInst))
|
||||
continue;
|
||||
|
||||
// Skip accesses in non-affine subregions as they might not be executed
|
||||
// under the same condition as the entry of the non-affine subregion.
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
; RUN: opt %loadPolly -polly-ignore-aliasing -polly-scops -analyze < %s | FileCheck %s
|
||||
; RUN: opt %loadPolly -polly-ignore-aliasing -polly-codegen -analyze < %s
|
||||
;
|
||||
; CHECK: Invariant Accesses: {
|
||||
; CHECK-NEXT: }
|
||||
;
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define void @cli_hex2int() {
|
||||
entry:
|
||||
br label %if.end
|
||||
|
||||
if.end: ; preds = %entry
|
||||
%call = call i16** @__ctype_b_loc() #0
|
||||
%tmp = load i16*, i16** %call, align 8
|
||||
%arrayidx = getelementptr inbounds i16, i16* %tmp, i64 0
|
||||
%tmp1 = load i16, i16* %arrayidx, align 2
|
||||
br i1 false, label %if.then.2, label %if.end.3
|
||||
|
||||
if.then.2: ; preds = %if.end
|
||||
br label %cleanup
|
||||
|
||||
if.end.3: ; preds = %if.end
|
||||
br label %cleanup
|
||||
|
||||
cleanup: ; preds = %if.end.3, %if.then.2
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind readnone
|
||||
declare i16** @__ctype_b_loc() #0
|
||||
|
||||
attributes #0 = { nounwind readnone }
|
Loading…
Reference in New Issue