[polly] r260025 - Make memory accesses with different element types optional

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 7 00:48:58 PST 2016


Author: grosser
Date: Sun Feb  7 02:48:57 2016
New Revision: 260025

URL: http://llvm.org/viewvc/llvm-project?rev=260025&view=rev
Log:
Make memory accesses with different element types optional

We also disable this feature by default, as there are still some issues in
combination with invariant load hoisting that slipped through my initial
testing.

Modified:
    polly/trunk/include/polly/ScopDetectionDiagnostic.h
    polly/trunk/lib/Analysis/ScopDetection.cpp
    polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp
    polly/trunk/lib/CodeGen/CodeGeneration.cpp
    polly/trunk/test/Isl/CodeGen/MemAccess/multiple_types.ll
    polly/trunk/test/Isl/CodeGen/invariant_load_different_sized_types.ll
    polly/trunk/test/Isl/CodeGen/multiple-types-invariant-load-2.ll
    polly/trunk/test/ScopInfo/multiple-types-access-offset-not-dividable-by-element-size.ll
    polly/trunk/test/ScopInfo/multiple-types-non-power-of-two-2.ll
    polly/trunk/test/ScopInfo/multiple-types-non-power-of-two.ll
    polly/trunk/test/ScopInfo/multiple-types-two-dimensional-2.ll
    polly/trunk/test/ScopInfo/multiple-types-two-dimensional.ll
    polly/trunk/test/ScopInfo/multiple-types.ll

Modified: polly/trunk/include/polly/ScopDetectionDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetectionDiagnostic.h?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopDetectionDiagnostic.h (original)
+++ polly/trunk/include/polly/ScopDetectionDiagnostic.h Sun Feb  7 02:48:57 2016
@@ -75,6 +75,7 @@ enum RejectReasonKind {
   rrkUndefBasePtr,
   rrkVariantBasePtr,
   rrkNonAffineAccess,
+  rrkDifferentElementSize,
   rrkLastAffFunc,
 
   rrkLoopBound,
@@ -509,6 +510,30 @@ public:
 
   /// @name LLVM-RTTI interface
   //@{
+  static bool classof(const RejectReason *RR);
+  //@}
+
+  /// @name RejectReason interface
+  //@{
+  virtual std::string getMessage() const override;
+  virtual std::string getEndUserMessage() const override;
+  //@}
+};
+
+//===----------------------------------------------------------------------===//
+/// @brief Report array accesses with differing element size.
+class ReportDifferentArrayElementSize : public ReportAffFunc {
+  //===--------------------------------------------------------------------===//
+
+  // The base pointer of the memory access.
+  const Value *BaseValue;
+
+public:
+  ReportDifferentArrayElementSize(const Instruction *Inst, const Value *V)
+      : ReportAffFunc(rrkDifferentElementSize, Inst), BaseValue(V) {}
+
+  /// @name LLVM-RTTI interface
+  //@{
   static bool classof(const RejectReason *RR);
   //@}
 

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Sun Feb  7 02:48:57 2016
@@ -121,6 +121,11 @@ static cl::opt<bool>
                 cl::desc("Print information about the activities of Polly"),
                 cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory));
 
+static cl::opt<bool> AllowDifferentTypes(
+    "polly-allow-differing-element-types",
+    cl::desc("Allow different element types for array accesses"), cl::Hidden,
+    cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory));
+
 static cl::opt<bool>
     AllowNonAffine("polly-allow-nonaffine",
                    cl::desc("Allow non affine access functions in arrays"),
@@ -787,11 +792,16 @@ bool ScopDetection::isValidMemoryAccess(
   AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
 
   const SCEV *Size = SE->getElementSize(Inst);
-  if (Context.ElementSize[BasePointer])
+  if (Context.ElementSize[BasePointer]) {
+    if (!AllowDifferentTypes && Context.ElementSize[BasePointer] != Size)
+      return invalid<ReportDifferentArrayElementSize>(Context, /*Assert=*/true,
+                                                      Inst, BaseValue);
+
     Context.ElementSize[BasePointer] =
         SE->getSMinExpr(Size, Context.ElementSize[BasePointer]);
-  else
+  } else {
     Context.ElementSize[BasePointer] = Size;
+  }
 
   bool isVariantInNonAffineLoop = false;
   SetVector<const Loop *> Loops;

Modified: polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp Sun Feb  7 02:48:57 2016
@@ -270,6 +270,24 @@ bool ReportVariantBasePtr::classof(const
 }
 
 //===----------------------------------------------------------------------===//
+// ReportDifferentArrayElementSize
+
+std::string ReportDifferentArrayElementSize::getMessage() const {
+  return "Access to one array through data types of different size";
+}
+
+bool ReportDifferentArrayElementSize::classof(const RejectReason *RR) {
+  return RR->getKind() == rrkDifferentElementSize;
+}
+
+std::string ReportDifferentArrayElementSize::getEndUserMessage() const {
+  llvm::StringRef BaseName = BaseValue->getName();
+  std::string Name = (BaseName.size() > 0) ? BaseName : "UNKNOWN";
+  return "The array \"" + Name + "\" is accessed through elements that differ "
+                                 "in size";
+}
+
+//===----------------------------------------------------------------------===//
 // ReportNonAffineAccess.
 
 std::string ReportNonAffineAccess::getMessage() const {

Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Sun Feb  7 02:48:57 2016
@@ -174,9 +174,6 @@ public:
       fixRegionInfo(EnteringBB->getParent(), R->getParent());
     }
 
-    assert(!verifyGeneratedFunction(S, *EnteringBB->getParent()) &&
-           "Verification of generated function failed");
-
     // Mark the function such that we run additional cleanup passes on this
     // function (e.g. mem2reg to rediscover phi nodes).
     Function *F = EnteringBB->getParent();

Modified: polly/trunk/test/Isl/CodeGen/MemAccess/multiple_types.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/MemAccess/multiple_types.ll?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/MemAccess/multiple_types.ll (original)
+++ polly/trunk/test/Isl/CodeGen/MemAccess/multiple_types.ll Sun Feb  7 02:48:57 2016
@@ -1,4 +1,5 @@
 ; RUN: opt %loadPolly -polly-import-jscop -polly-import-jscop-dir=%S \
+; RUN: -polly-allow-differing-element-types \
 ; RUN:   -polly-codegen -S    < %s | FileCheck %s
 ;
 ;    // Check that accessing one array with different types works.

Modified: polly/trunk/test/Isl/CodeGen/invariant_load_different_sized_types.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/invariant_load_different_sized_types.ll?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/invariant_load_different_sized_types.ll (original)
+++ polly/trunk/test/Isl/CodeGen/invariant_load_different_sized_types.ll Sun Feb  7 02:48:57 2016
@@ -1,4 +1,5 @@
-; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-codegen -S \
+; RUN: -polly-allow-differing-element-types < %s | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 

Modified: polly/trunk/test/Isl/CodeGen/multiple-types-invariant-load-2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/multiple-types-invariant-load-2.ll?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/multiple-types-invariant-load-2.ll (original)
+++ polly/trunk/test/Isl/CodeGen/multiple-types-invariant-load-2.ll Sun Feb  7 02:48:57 2016
@@ -1,4 +1,5 @@
-; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-codegen -S \
+; RUN: -polly-allow-differing-element-types < %s | FileCheck %s
 
 ; CHECK: polly
 

Modified: polly/trunk/test/ScopInfo/multiple-types-access-offset-not-dividable-by-element-size.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multiple-types-access-offset-not-dividable-by-element-size.ll?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multiple-types-access-offset-not-dividable-by-element-size.ll (original)
+++ polly/trunk/test/ScopInfo/multiple-types-access-offset-not-dividable-by-element-size.ll Sun Feb  7 02:48:57 2016
@@ -1,4 +1,5 @@
 ; RUN: opt %loadPolly -polly-scops -pass-remarks-analysis="polly-scops" \
+; RUN: -polly-allow-differing-element-types \
 ; RUN:                -analyze < %s  2>&1 | FileCheck %s
 ;
 ;    // For the following accesses the offset expression from the base pointer

Modified: polly/trunk/test/ScopInfo/multiple-types-non-power-of-two-2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multiple-types-non-power-of-two-2.ll?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multiple-types-non-power-of-two-2.ll (original)
+++ polly/trunk/test/ScopInfo/multiple-types-non-power-of-two-2.ll Sun Feb  7 02:48:57 2016
@@ -1,4 +1,5 @@
-; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-scops -analyze \
+; RUN: -polly-allow-differing-element-types < %s | FileCheck %s
 ;
 ;  void multiple_types(i128 *A) {
 ;    for (long i = 0; i < 100; i++) {

Modified: polly/trunk/test/ScopInfo/multiple-types-non-power-of-two.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multiple-types-non-power-of-two.ll?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multiple-types-non-power-of-two.ll (original)
+++ polly/trunk/test/ScopInfo/multiple-types-non-power-of-two.ll Sun Feb  7 02:48:57 2016
@@ -1,4 +1,5 @@
-; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-scops -analyze \
+; RUN: -polly-allow-differing-element-types < %s | FileCheck %s
 ;
 ;  void multiple_types(i8 *A) {
 ;    for (long i = 0; i < 100; i++) {

Modified: polly/trunk/test/ScopInfo/multiple-types-two-dimensional-2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multiple-types-two-dimensional-2.ll?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multiple-types-two-dimensional-2.ll (original)
+++ polly/trunk/test/ScopInfo/multiple-types-two-dimensional-2.ll Sun Feb  7 02:48:57 2016
@@ -1,4 +1,5 @@
 ; RUN: opt %loadPolly -polly-scops -pass-remarks-analysis="polly-scops" \
+; RUN:                -polly-allow-differing-element-types \
 ; RUN:                -analyze < %s  2>&1 | FileCheck %s
 ;
 ;

Modified: polly/trunk/test/ScopInfo/multiple-types-two-dimensional.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multiple-types-two-dimensional.ll?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multiple-types-two-dimensional.ll (original)
+++ polly/trunk/test/ScopInfo/multiple-types-two-dimensional.ll Sun Feb  7 02:48:57 2016
@@ -1,4 +1,5 @@
 ; RUN: opt %loadPolly -polly-scops -pass-remarks-analysis="polly-scops" \
+; RUN: -polly-allow-differing-element-types \
 ; RUN:                -analyze < %s  2>&1 | FileCheck %s
 ;
 ;    void foo(long n, long m, char A[][m]) {

Modified: polly/trunk/test/ScopInfo/multiple-types.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multiple-types.ll?rev=260025&r1=260024&r2=260025&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multiple-types.ll (original)
+++ polly/trunk/test/ScopInfo/multiple-types.ll Sun Feb  7 02:48:57 2016
@@ -1,4 +1,5 @@
-; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-scops -analyze \
+; RUN: -polly-allow-differing-element-types < %s | FileCheck %s
 ;
 ;    // Check that accessing one array with different types works.
 ;    void multiple_types(char *Short, char *Float, char *Double) {




More information about the llvm-commits mailing list