[polly] r250958 - [FIX] Do not hoist nested variant base pointers
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 21 15:14:57 PDT 2015
Author: jdoerfert
Date: Wed Oct 21 17:14:57 2015
New Revision: 250958
URL: http://llvm.org/viewvc/llvm-project?rev=250958&view=rev
Log:
[FIX] Do not hoist nested variant base pointers
This fixes bug 25249.
Added:
polly/trunk/test/ScopInfo/variant_base_pointer.ll
Modified:
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=250958&r1=250957&r2=250958&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Oct 21 17:14:57 2015
@@ -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.
Added: polly/trunk/test/ScopInfo/variant_base_pointer.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/variant_base_pointer.ll?rev=250958&view=auto
==============================================================================
--- polly/trunk/test/ScopInfo/variant_base_pointer.ll (added)
+++ polly/trunk/test/ScopInfo/variant_base_pointer.ll Wed Oct 21 17:14:57 2015
@@ -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 }
More information about the llvm-commits
mailing list