diff options
15 files changed, 62 insertions, 47 deletions
diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index 517ac79b372..f1a4b4124b3 100644 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -186,6 +186,12 @@ public: /// @brief Get the base array isl_id for this access. __isl_give isl_id *getArrayId() const; + /// @brief Return a string representation of the accesse's reduction type. + const std::string getReductionOperatorStr() const; + + /// @brief Return a string representation of the reduction type @p RT. + static const std::string getReductionOperatorStr(ReductionType RT); + const std::string &getBaseName() const { return BaseName; } const Instruction *getAccessInstruction() const { return Inst; } diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index 6fa73f061d0..aa63e248af8 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -272,6 +272,27 @@ int SCEVAffinator::getLoopDepth(const Loop *L) { return L->getLoopDepth() - outerLoop->getLoopDepth(); } +const std::string +MemoryAccess::getReductionOperatorStr(MemoryAccess::ReductionType RT) { + switch (RT) { + case MemoryAccess::RT_NONE: + llvm_unreachable("Requested a reduction operator string for a memory " + "access which isn't a reduction"); + case MemoryAccess::RT_ADD: + return "+"; + case MemoryAccess::RT_MUL: + return "*"; + case MemoryAccess::RT_BOR: + return "|"; + case MemoryAccess::RT_BXOR: + return "^"; + case MemoryAccess::RT_BAND: + return "&"; + } + llvm_unreachable("Unknown reduction type"); + return ""; +} + /// @brief Return the reduction type for a given binary operator static MemoryAccess::ReductionType getReductionType(const BinaryOperator *BinOp, const Instruction *Load) { @@ -461,28 +482,16 @@ void MemoryAccess::realignParams() { AccessRelation = isl_map_align_params(AccessRelation, ParamSpace); } +const std::string MemoryAccess::getReductionOperatorStr() const { + return MemoryAccess::getReductionOperatorStr(getReductionType()); +} + raw_ostream &polly::operator<<(raw_ostream &OS, MemoryAccess::ReductionType RT) { - switch (RT) { - case MemoryAccess::RT_NONE: + if (RT == MemoryAccess::RT_NONE) OS << "NONE"; - break; - case MemoryAccess::RT_ADD: - OS << "ADD"; - break; - case MemoryAccess::RT_MUL: - OS << "MUL"; - break; - case MemoryAccess::RT_BOR: - OS << "BOR"; - break; - case MemoryAccess::RT_BXOR: - OS << "BXOR"; - break; - case MemoryAccess::RT_BAND: - OS << "BAND"; - break; - } + else + OS << MemoryAccess::getReductionOperatorStr(RT); return OS; } diff --git a/polly/test/ScopInfo/reduction_chain_partially_outside_the_scop.ll b/polly/test/ScopInfo/reduction_chain_partially_outside_the_scop.ll index 248d29e3502..42d768e7fd5 100644 --- a/polly/test/ScopInfo/reduction_chain_partially_outside_the_scop.ll +++ b/polly/test/ScopInfo/reduction_chain_partially_outside_the_scop.ll @@ -1,6 +1,6 @@ ; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s ; -; CHECK-NOT: Reduction like: 1 +; CHECK: Reduction Type: NONE ; ; int c, d; ; void f(int *sum) { diff --git a/polly/test/ScopInfo/reduction_disabled_multiplicative.ll b/polly/test/ScopInfo/reduction_disabled_multiplicative.ll index 4a3ccfadee4..5e32129c253 100644 --- a/polly/test/ScopInfo/reduction_disabled_multiplicative.ll +++ b/polly/test/ScopInfo/reduction_disabled_multiplicative.ll @@ -1,8 +1,8 @@ ; RUN: opt -basicaa %loadPolly -polly-scops -analyze -polly-disable-multiplicative-reductions < %s | FileCheck %s ; -; CHECK: ReadAccess := [Reduction Type: ADD +; CHECK: ReadAccess := [Reduction Type: + ; CHECK: { Stmt_for_body[i0] -> MemRef_sum[0] }; -; CHECK: MustWriteAccess := [Reduction Type: ADD +; CHECK: MustWriteAccess := [Reduction Type: + ; CHECK: { Stmt_for_body[i0] -> MemRef_sum[0] }; ; CHECK: ReadAccess := [Reduction Type: NONE ; CHECK: { Stmt_for_body[i0] -> MemRef_prod[0] }; diff --git a/polly/test/ScopInfo/reduction_invalid_different_operators.ll b/polly/test/ScopInfo/reduction_invalid_different_operators.ll index c519c5f5c76..9f477fed4bc 100644 --- a/polly/test/ScopInfo/reduction_invalid_different_operators.ll +++ b/polly/test/ScopInfo/reduction_invalid_different_operators.ll @@ -10,8 +10,8 @@ ; return sum + sth; ; } ; -; CHECK-NOT: Reduction Type: ADD -; CHECK-NOT: Reduction Type: MUL +; CHECK-NOT: Reduction Type: + +; CHECK-NOT: Reduction Type: * target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64" define i32 @f() { diff --git a/polly/test/ScopInfo/reduction_invalid_overlapping_accesses.ll b/polly/test/ScopInfo/reduction_invalid_overlapping_accesses.ll index 2c0db4db2a8..2c765f78f8f 100644 --- a/polly/test/ScopInfo/reduction_invalid_overlapping_accesses.ll +++ b/polly/test/ScopInfo/reduction_invalid_overlapping_accesses.ll @@ -10,8 +10,8 @@ ; } ; } ; -; CHECK-NOT: Reduction Type: ADD -; CHECK-NOT: Reduction Type: MUL +; CHECK-NOT: Reduction Type: + +; CHECK-NOT: Reduction Type: * target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64" define void @f(i32* %sums) { diff --git a/polly/test/ScopInfo/reduction_multiple_loops_array_sum.ll b/polly/test/ScopInfo/reduction_multiple_loops_array_sum.ll index 7a956ac7f52..d61f5210af9 100644 --- a/polly/test/ScopInfo/reduction_multiple_loops_array_sum.ll +++ b/polly/test/ScopInfo/reduction_multiple_loops_array_sum.ll @@ -1,21 +1,21 @@ ; RUN: opt -basicaa %loadPolly -polly-scops -analyze < %s | FileCheck %s ; ; CHECK: Stmt_for_body -; CHECK: Reduction Type: MUL +; CHECK: Reduction Type: * ; CHECK: MemRef_sum -; CHECK: Reduction Type: MUL +; CHECK: Reduction Type: * ; CHECK: MemRef_sum ; CHECK: Stmt_for_body3 ; CHECK: Reduction Type: NONE ; CHECK: MemRef_A -; CHECK: Reduction Type: ADD +; CHECK: Reduction Type: + ; CHECK: MemRef_sum -; CHECK: Reduction Type: ADD +; CHECK: Reduction Type: + ; CHECK: MemRef_sum ; CHECK: Stmt_for_end -; CHECK: Reduction Type: MUL +; CHECK: Reduction Type: * ; CHECK: MemRef_sum -; CHECK: Reduction Type: MUL +; CHECK: Reduction Type: * ; CHECK: MemRef_sum ; ; void f(int *restrict A, int *restrict sum) { diff --git a/polly/test/ScopInfo/reduction_multiple_loops_array_sum_1.ll b/polly/test/ScopInfo/reduction_multiple_loops_array_sum_1.ll index 4104aabcea7..19147fe37e0 100644 --- a/polly/test/ScopInfo/reduction_multiple_loops_array_sum_1.ll +++ b/polly/test/ScopInfo/reduction_multiple_loops_array_sum_1.ll @@ -6,11 +6,11 @@ ; CHECK: Reduction Type: NONE ; CHECK: MemRef_sum_12 ; CHECK: Stmt_for_inc -; CHECK: Reduction Type: ADD +; CHECK: Reduction Type: + ; CHECK: MemRef_sum_12 ; CHECK: Reduction Type: NONE ; CHECK: MemRef_A -; CHECK: Reduction Type: ADD +; CHECK: Reduction Type: + ; CHECK: MemRef_sum_12 ; CHECK: Stmt_for_inc5 ; CHECK: Reduction Type: NONE diff --git a/polly/test/ScopInfo/reduction_multiple_simple_binary.ll b/polly/test/ScopInfo/reduction_multiple_simple_binary.ll index 49e49188995..c701ed1d33b 100644 --- a/polly/test/ScopInfo/reduction_multiple_simple_binary.ll +++ b/polly/test/ScopInfo/reduction_multiple_simple_binary.ll @@ -6,9 +6,9 @@ ; CHECK: { Stmt_for_body[i0] -> MemRef_A[i0] }; ; CHECK: MustWriteAccess := [Reduction Type: NONE ; CHECK: { Stmt_for_body[i0] -> MemRef_first[0] }; -; CHECK: ReadAccess := [Reduction Type: ADD +; CHECK: ReadAccess := [Reduction Type: + ; CHECK: { Stmt_for_body[i0] -> MemRef_sum[0] }; -; CHECK: MustWriteAccess := [Reduction Type: ADD +; CHECK: MustWriteAccess := [Reduction Type: + ; CHECK: { Stmt_for_body[i0] -> MemRef_sum[0] }; ; CHECK: ReadAccess := [Reduction Type: NONE ; CHECK: { Stmt_for_body[i0] -> MemRef_A[-1 + i0] }; @@ -16,9 +16,9 @@ ; CHECK: { Stmt_for_body[i0] -> MemRef_A[i0] }; ; CHECK: MustWriteAccess := [Reduction Type: NONE ; CHECK: { Stmt_for_body[i0] -> MemRef_middle[0] }; -; CHECK: ReadAccess := [Reduction Type: MUL +; CHECK: ReadAccess := [Reduction Type: * ; CHECK: { Stmt_for_body[i0] -> MemRef_prod[0] }; -; CHECK: MustWriteAccess := [Reduction Type: MUL +; CHECK: MustWriteAccess := [Reduction Type: * ; CHECK: { Stmt_for_body[i0] -> MemRef_prod[0] }; ; CHECK: ReadAccess := [Reduction Type: NONE ; CHECK: { Stmt_for_body[i0] -> MemRef_A[-1 + i0] }; diff --git a/polly/test/ScopInfo/reduction_non_overlapping_chains.ll b/polly/test/ScopInfo/reduction_non_overlapping_chains.ll index ef729552254..e9399ba2127 100644 --- a/polly/test/ScopInfo/reduction_non_overlapping_chains.ll +++ b/polly/test/ScopInfo/reduction_non_overlapping_chains.ll @@ -1,9 +1,9 @@ ; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s ; -; CHECK: Reduction Type: ADD -; CHECK: Reduction Type: ADD -; CHECK: Reduction Type: MUL -; CHECK: Reduction Type: MUL +; CHECK: Reduction Type: + +; CHECK: Reduction Type: + +; CHECK: Reduction Type: * +; CHECK: Reduction Type: * ; ; void f(int *sums) { ; for (int i = 0; i < 1024; i++) { diff --git a/polly/test/ScopInfo/reduction_only_reduction_like_access.ll b/polly/test/ScopInfo/reduction_only_reduction_like_access.ll index 1cc98b05bfa..f0009ae71d3 100644 --- a/polly/test/ScopInfo/reduction_only_reduction_like_access.ll +++ b/polly/test/ScopInfo/reduction_only_reduction_like_access.ll @@ -1,6 +1,6 @@ ; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s ; -; CHECK: Reduction Type: ADD +; CHECK: Reduction Type: + ; ; void f(int *sum) { ; for (int i = 0; i < 100; i++) diff --git a/polly/test/ScopInfo/reduction_simple_fp.ll b/polly/test/ScopInfo/reduction_simple_fp.ll index 41af402be2a..7918fcbe9b6 100644 --- a/polly/test/ScopInfo/reduction_simple_fp.ll +++ b/polly/test/ScopInfo/reduction_simple_fp.ll @@ -3,7 +3,7 @@ ; CHECK: Function: f_no_fast_math ; CHECK: Reduction Type: NONE ; CHECK: Function: f_fast_math -; CHECK: Reduction Type: ADD +; CHECK: Reduction Type: + ; ; void f(float *sum) { ; for (int i = 0; i < 100; i++) diff --git a/polly/test/ScopInfo/reduction_simple_w_constant.ll b/polly/test/ScopInfo/reduction_simple_w_constant.ll index ad5fdea1933..2cecb4dfc19 100644 --- a/polly/test/ScopInfo/reduction_simple_w_constant.ll +++ b/polly/test/ScopInfo/reduction_simple_w_constant.ll @@ -1,6 +1,6 @@ ; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s ; -; CHECK: Reduction Type: ADD +; CHECK: Reduction Type: + ; ; void f(int *sum) { ; for (int i = 0; i <= 100; i++) diff --git a/polly/test/ScopInfo/reduction_simple_w_iv.ll b/polly/test/ScopInfo/reduction_simple_w_iv.ll index c123c9b9028..982983cf4db 100644 --- a/polly/test/ScopInfo/reduction_simple_w_iv.ll +++ b/polly/test/ScopInfo/reduction_simple_w_iv.ll @@ -1,6 +1,6 @@ ; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s ; -; CHECK: Reduction Type: ADD +; CHECK: Reduction Type: + ; ; void f(int* sum) { ; for (int i = 0; i <= 100; i++) diff --git a/polly/test/ScopInfo/reduction_two_identical_reads.ll b/polly/test/ScopInfo/reduction_two_identical_reads.ll index 160441bf06d..1d71d7de40e 100644 --- a/polly/test/ScopInfo/reduction_two_identical_reads.ll +++ b/polly/test/ScopInfo/reduction_two_identical_reads.ll @@ -1,6 +1,6 @@ ; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s ; -; CHECK-NOT: Reduction like: 1 +; CHECK: Reduction Type: NONE ; ; Check that we do not mark these accesses as reduction like. ; We do this for the case the loads are modelt with the same LLVM-IR value and |

