[polly] r316983 - [OpenMP] Fix reference collection of latest base ptrs.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 03:28:22 PDT 2017


Author: meinersbur
Date: Tue Oct 31 03:28:22 2017
New Revision: 316983

URL: http://llvm.org/viewvc/llvm-project?rev=316983&view=rev
Log:
[OpenMP] Fix reference collection of latest base ptrs.

When collecting base pointers that need to be made available in parallel
subfunctions, use the base pointer associated with the latest
ScopArrayInfo, instead of the original one.

Added:
    polly/trunk/test/Isl/CodeGen/OpenMP/reference_latest.ll
Modified:
    polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
    polly/trunk/test/Isl/CodeGen/OpenMP/mapped-phi-access.ll

Modified: polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslNodeBuilder.cpp?rev=316983&r1=316982&r2=316983&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslNodeBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslNodeBuilder.cpp Tue Oct 31 03:28:22 2017
@@ -263,7 +263,7 @@ isl_stat addReferencesFromStmt(const Sco
     }
 
     if (Access->isLatestArrayKind()) {
-      auto *BasePtr = Access->getScopArrayInfo()->getBasePtr();
+      auto *BasePtr = Access->getLatestScopArrayInfo()->getBasePtr();
       if (Instruction *OpInst = dyn_cast<Instruction>(BasePtr))
         if (Stmt->getParent()->contains(OpInst))
           continue;

Modified: polly/trunk/test/Isl/CodeGen/OpenMP/mapped-phi-access.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/OpenMP/mapped-phi-access.ll?rev=316983&r1=316982&r2=316983&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/OpenMP/mapped-phi-access.ll (original)
+++ polly/trunk/test/Isl/CodeGen/OpenMP/mapped-phi-access.ll Tue Oct 31 03:28:22 2017
@@ -53,6 +53,6 @@ attributes #0 = { nounwind uwtable "corr
 ; CHECK-LABEL: define internal void @main_polly_subfn(i8* %polly.par.userContext)
 ;
 ; CHECK:       polly.stmt.for.body65.i226:
-; CHECK-NEXT:    %polly.access.cast.polly.subfunc.arg.2 = bitcast i8* %polly.subfunc.arg.2 to double*
-; CHECK-NEXT:    %polly.access.polly.subfunc.arg.2 = getelementptr double, double* %polly.access.cast.polly.subfunc.arg.2, i64 %polly.indvar
-; CHECK-NEXT:    store double undef, double* %polly.access.polly.subfunc.arg.2
+; CHECK-NEXT:    %polly.access.cast.polly.subfunc.arg.[[R0:[0-9]*]] = bitcast i8* %polly.subfunc.arg.{{[0-9]*}} to double*
+; CHECK-NEXT:    %polly.access.polly.subfunc.arg.[[R1:[0-9]*]] = getelementptr double, double* %polly.access.cast.polly.subfunc.arg.[[R0]], i64 %polly.indvar
+; CHECK-NEXT:    store double undef, double* %polly.access.polly.subfunc.arg.[[R1]]

Added: polly/trunk/test/Isl/CodeGen/OpenMP/reference_latest.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/OpenMP/reference_latest.ll?rev=316983&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/OpenMP/reference_latest.ll (added)
+++ polly/trunk/test/Isl/CodeGen/OpenMP/reference_latest.ll Tue Oct 31 03:28:22 2017
@@ -0,0 +1,44 @@
+; RUN: opt %loadPolly -polly-delicm -polly-simplify -polly-parallel -polly-codegen -S < %s | FileCheck %s
+;
+; Test that parallel codegen handles scalars mapped to other arrays.
+; After mapping "store double %add10" references the array "MemRef2".
+; Its base pointer therefore needs to be made available in the subfunction.
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @reference_latest(float* nocapture readonly %data, i32 %n, i32 %m) {
+entry:
+  %0 = alloca double, i64 undef, align 16
+  %conv1 = sext i32 %m to i64
+  br label %while.body
+
+while.body:
+  %indvars.iv211 = phi i64 [ %conv1, %entry ], [ %indvars.iv.next212, %for.end ]
+  br label %for.body
+
+for.body:
+  %indvars.iv207 = phi i64 [ %indvars.iv211, %while.body ], [ %indvars.iv.next208, %for.body ]
+  %arrayidx7 = getelementptr inbounds float, float* %data, i64 0
+  %1 = load float, float* %arrayidx7, align 4
+  %add10 = fadd double undef, undef
+  %indvars.iv.next208 = add nsw i64 %indvars.iv207, 1
+  %lftr.wideiv = trunc i64 %indvars.iv.next208 to i32
+  %exitcond210 = icmp eq i32 %lftr.wideiv, %n
+  br i1 %exitcond210, label %for.end, label %for.body
+
+for.end:
+  %arrayidx12 = getelementptr inbounds double, double* %0, i64 %indvars.iv211
+  store double %add10, double* %arrayidx12, align 8
+  %indvars.iv.next212 = add nsw i64 %indvars.iv211, -1
+  %2 = trunc i64 %indvars.iv211 to i32
+  %tobool = icmp eq i32 %2, 0
+  br i1 %tobool, label %while.end, label %while.body
+
+while.end:
+  ret void
+}
+
+; CHECK-LABEL: define internal void @reference_latest_polly_subfn(i8* %polly.par.userContext)
+
+; CHECK:      %polly.access.polly.subfunc.arg. = getelementptr double, double* %polly.subfunc.arg., i64 %{{[0-9]+}}
+; CHECK-NEXT: store double %p_add{{[0-9]*}}, double* %polly.access.polly.subfunc.arg.




More information about the llvm-commits mailing list