[polly] r251881 - [FIX] Correctly update SAI base pointer

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 17:42:59 PST 2015


Author: jdoerfert
Date: Mon Nov  2 19:42:59 2015
New Revision: 251881

URL: http://llvm.org/viewvc/llvm-project?rev=251881&view=rev
Log:
[FIX] Correctly update SAI base pointer

  If a base pointer load is preloaded, we have change the base pointer of
  the derived SAI. However, as the derived SAI relationship is is
  coarse grained, we need to check if we actually preloaded the base
  pointer or a different element of the base pointer SAI array.


Added:
    polly/trunk/test/Isl/CodeGen/conflict-between-loop-invariant-code-hosting-and-escape-map-computation.ll
Modified:
    polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
    polly/trunk/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll
    polly/trunk/test/ScopInfo/invariant_load_access_classes_different_base_type_same_pointer_escaping.ll

Modified: polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslNodeBuilder.cpp?rev=251881&r1=251880&r2=251881&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslNodeBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslNodeBuilder.cpp Mon Nov  2 19:42:59 2015
@@ -960,8 +960,16 @@ void IslNodeBuilder::preloadInvariantEqu
   auto *SAI = S.getScopArrayInfo(MA->getBaseAddr());
   for (auto *DerivedSAI : SAI->getDerivedSAIs()) {
     Value *BasePtr = DerivedSAI->getBasePtr();
-    BasePtr = Builder.CreateBitOrPointerCast(PreloadVal, BasePtr->getType());
-    DerivedSAI->setBasePtr(BasePtr);
+
+    // As the derived SAI information is quite coarse, any load from the current
+    // SAI could be the base pointer of the derived SAI, however we should only
+    // change the base pointer of the derived SAI if we actually preloaded it.
+    for (const MemoryAccess *MA : MAs) {
+      if (BasePtr != MA->getBaseAddr())
+        continue;
+      BasePtr = Builder.CreateBitOrPointerCast(PreloadVal, BasePtr->getType());
+      DerivedSAI->setBasePtr(BasePtr);
+    }
   }
 
   BasicBlock *EntryBB = &Builder.GetInsertBlock()->getParent()->getEntryBlock();

Added: polly/trunk/test/Isl/CodeGen/conflict-between-loop-invariant-code-hosting-and-escape-map-computation.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/conflict-between-loop-invariant-code-hosting-and-escape-map-computation.ll?rev=251881&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/conflict-between-loop-invariant-code-hosting-and-escape-map-computation.ll (added)
+++ polly/trunk/test/Isl/CodeGen/conflict-between-loop-invariant-code-hosting-and-escape-map-computation.ll Mon Nov  2 19:42:59 2015
@@ -0,0 +1,50 @@
+; RUN: opt %loadPolly -polly-process-unprofitable -analyze -polly-codegen < %s
+;
+; CHECK: store i32 %tmp14_p_scalar_, i32* %tmp14.s2a
+; CHECK: %tmp14.final_reload = load i32, i32* %tmp14.s2a
+; CHECK: %tmp17b.final_reload = load i32, i32* %tmp17b.preload.s2a
+; CHECK: %tmp17.final_reload = load i32, i32* %tmp17.preload.s2a
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+; Function Attrs: nounwind uwtable
+define void @hoge(i8* %arg, i32 %arg4) #0 {
+bb:
+  br label %bb5
+
+bb5:                                              ; preds = %bb
+  br i1 undef, label %bb6, label %bb18
+
+bb6:                                              ; preds = %bb5
+  %tmp7 = getelementptr i8, i8* %arg, i64 0
+  %tmp8 = getelementptr inbounds i8, i8* %tmp7, i64 4
+  %tmp9 = getelementptr inbounds i8, i8* %tmp8, i64 20
+  br label %bb10
+
+bb10:                                             ; preds = %bb10, %bb6
+  %tmp11 = phi i32 [ %tmp12, %bb10 ], [ 2, %bb6 ]
+  %tmp12 = add nuw nsw i32 %tmp11, 1
+  br i1 false, label %bb10, label %bb13
+
+bb13:                                             ; preds = %bb10
+  %tmp = bitcast i8* %tmp9 to i32*
+  %tmp14 = load i32, i32* %tmp, align 4
+  %tmp15 = getelementptr inbounds i8, i8* %tmp9, i64 4
+  %tmp16 = bitcast i8* %tmp15 to i32*
+  %tmp17 = load i32, i32* %tmp16, align 4
+  store i32 %tmp17, i32* %tmp, align 4
+  %tmp15b = getelementptr inbounds i8, i8* %tmp9, i64 8
+  %tmp16b = bitcast i8* %tmp15b to i32*
+  %tmp17b = load i32, i32* %tmp16b, align 4
+  store i32 %tmp17b, i32* %tmp, align 4
+  br label %bb19
+
+bb18:                                             ; preds = %bb5
+  br label %bb19
+
+bb19:                                             ; preds = %bb18, %bb13
+  %tmp20 = phi i32 [ %tmp14, %bb13 ], [ %arg4, %bb18 ]
+  %tmp21 = phi i32 [ %tmp17, %bb13 ], [ %arg4, %bb18 ]
+  %tmp22 = phi i32 [ %tmp17b, %bb13 ], [ %arg4, %bb18 ]
+  unreachable
+}

Modified: polly/trunk/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll?rev=251881&r1=251880&r2=251881&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll (original)
+++ polly/trunk/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll Mon Nov  2 19:42:59 2015
@@ -45,12 +45,10 @@
 ;
 ; CODEGEN: polly.preload.begin:
 ; CODEGEN:   %.load = load i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @S, i32 0, i32 0)
-; CODEGEN:   %0 = bitcast i32 %.load to float
 ; CODEGEN:   store i32 %.load, i32* %S.a.preload.s2a
 ; CODEGEN:   %.load1 = load i32, i32* getelementptr (i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @S, i32 0, i32 0), i64 1)
-; CODEGEN:   %1 = bitcast i32 %.load1 to float
-; CODEGEN:   %2 = bitcast float %1 to i32
-; CODEGEN:   store float %1, float* %S.b.preload.s2a
+; CODEGEN:   %0 = bitcast i32 %.load1 to float
+; CODEGEN:   store float %0, float* %S.b.preload.s2a
 ;
 ; CODEGEN:     polly.merge_new_and_old:
 ; CODEGEN-DAG:   %S.b.merge = phi float [ %S.b.final_reload, %polly.loop_exit ], [ %S.b, %do.cond ]

Modified: polly/trunk/test/ScopInfo/invariant_load_access_classes_different_base_type_same_pointer_escaping.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/invariant_load_access_classes_different_base_type_same_pointer_escaping.ll?rev=251881&r1=251880&r2=251881&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/invariant_load_access_classes_different_base_type_same_pointer_escaping.ll (original)
+++ polly/trunk/test/ScopInfo/invariant_load_access_classes_different_base_type_same_pointer_escaping.ll Mon Nov  2 19:42:59 2015
@@ -42,12 +42,12 @@
 ;
 ; CODEGEN:     polly.merge_new_and_old:
 ; CODEGEN-DAG:   %U.f.merge = phi float [ %U.f.final_reload, %polly.loop_exit ], [ %U.f, %do.cond ]
-; CODEGEN-DAG:   %U.i.merge = phi i32 [ %7, %polly.loop_exit ], [ %U.i, %do.cond ]
+; CODEGEN-DAG:   %U.i.merge = phi i32 [ %6, %polly.loop_exit ], [ %U.i, %do.cond ]
 ;
 ; CODEGEN: polly.loop_exit:
 ; CODEGEN-DAG:   %U.f.final_reload = load float, float* %U.f.preload.s2a
 ; CODEGEN-DAG:   %U.i.final_reload = load float, float* %U.f.preload.s2a
-; CODEGEN-DAG:   %7 = bitcast float %U.i.final_reload to i32
+; CODEGEN-DAG:   %6 = bitcast float %U.i.final_reload to i32
 ;
 ; CODEGEN: polly.stmt.do.body:
 ; CODEGEN:   %p_conv = fptosi float %0 to i32




More information about the llvm-commits mailing list