[polly] r206332 - Fix for vector codegen in OpenMP subfunctions

Tobias Grosser tobias at grosser.es
Tue Apr 15 15:30:06 PDT 2014


Author: grosser
Date: Tue Apr 15 17:30:06 2014
New Revision: 206332

URL: http://llvm.org/viewvc/llvm-project?rev=206332&view=rev
Log:
Fix for vector codegen in OpenMP subfunctions

Contributed-by: Johannes Doerfert <doerfert at cs.uni-saarland.de>

Added:
    polly/trunk/test/Cloog/CodeGen/OpenMP/vector-codegen-in-openmp-subfunc.ll
Modified:
    polly/trunk/lib/CodeGen/CodeGeneration.cpp

Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=206332&r1=206331&r2=206332&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Tue Apr 15 17:30:06 2014
@@ -481,6 +481,13 @@ void ClastStmtCodeGen::codegen(const cla
     }
   }
 
+  // Copy the current value map into all vector maps if the key wasn't
+  // available yet. This is needed in case vector codegen is performed in
+  // OpenMP subfunctions.
+  for (auto KV : ValueMap)
+    for (int i = 0; i < VectorDimensions; ++i)
+      VectorMap[i].insert(KV);
+
   isl_map *Schedule = extractPartialSchedule(Statement, Domain);
   VectorBlockGenerator::generate(Builder, *Statement, VectorMap, VLTS, Schedule,
                                  P);

Added: polly/trunk/test/Cloog/CodeGen/OpenMP/vector-codegen-in-openmp-subfunc.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Cloog/CodeGen/OpenMP/vector-codegen-in-openmp-subfunc.ll?rev=206332&view=auto
==============================================================================
--- polly/trunk/test/Cloog/CodeGen/OpenMP/vector-codegen-in-openmp-subfunc.ll (added)
+++ polly/trunk/test/Cloog/CodeGen/OpenMP/vector-codegen-in-openmp-subfunc.ll Tue Apr 15 17:30:06 2014
@@ -0,0 +1,48 @@
+; RUN: opt %loadPolly -basicaa -polly-vectorizer=polly -enable-polly-openmp -polly-opt-isl -polly-codegen < %s
+
+; void f(int *A, int a, int b) {
+;   int local = a > b ? a : b;
+;   int i;
+;   for (i = 0; i < 100; i++) {
+;     A[i] += local;
+;   }
+; }
+;
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @f(i32* %A, i32 %a, i32 %b) {
+entry:
+  %cmp = icmp sgt i32 %a, %b
+  br i1 %cmp, label %cond.true, label %cond.false
+
+cond.true:                                        ; preds = %entry
+  br label %cond.end
+
+cond.false:                                       ; preds = %entry
+  br label %cond.end
+
+cond.end:                                         ; preds = %cond.false, %cond.true
+  %cond = phi i32 [ %a, %cond.true ], [ %b, %cond.false ]
+  br label %for.cond
+
+for.cond:                                         ; preds = %for.inc, %cond.end
+  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %cond.end ]
+  %exitcond = icmp ne i64 %indvars.iv, 100
+  br i1 %exitcond, label %for.body, label %for.end
+
+for.body:                                         ; preds = %for.cond
+  %arrayidx = getelementptr inbounds i32* %A, i64 %indvars.iv
+  %tmp = load i32* %arrayidx, align 4
+  %add = add nsw i32 %tmp, %cond
+  store i32 %add, i32* %arrayidx, align 4
+  br label %for.inc
+
+for.inc:                                          ; preds = %for.body
+  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+  br label %for.cond
+
+for.end:                                          ; preds = %for.cond
+  ret void
+}





More information about the llvm-commits mailing list