[PATCH] D32027: [Polly][DeLICM] Use Known information when comparing Existing.Written and Proposed.Written. NFC.
Michael Kruse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 13 09:51:39 PDT 2017
Meinersbur created this revision.
Meinersbur added a project: Polly.
https://reviews.llvm.org/D32027
Files:
lib/Transform/DeLICM.cpp
unittests/DeLICM/DeLICMTest.cpp
Index: unittests/DeLICM/DeLICMTest.cpp
===================================================================
--- unittests/DeLICM/DeLICMTest.cpp
+++ unittests/DeLICM/DeLICMTest.cpp
@@ -278,5 +278,13 @@
{"{}", nullptr, "{ Dom[0] }"}));
EXPECT_FALSE(checkIsConflicting({"{}", nullptr, "{ Dom[1] }"},
{"{}", nullptr, "{ Dom[0] }"}));
+
+ // Check written vs. written with known values.
+ EXPECT_FALSE(checkIsConflictingKnown({"{}", nullptr, "{ Dom[0] -> Val[] }"},
+ {"{}", nullptr, "{ Dom[0] -> Val[] }"}));
+ EXPECT_TRUE(checkIsConflictingKnown({"{}", nullptr, "{ Dom[0] -> ValA[] }"},
+ {"{}", nullptr, "{ Dom[0] -> ValB[] }"}));
+ EXPECT_TRUE(checkIsConflictingKnown({"{}", nullptr, "{ Dom[0] -> Val[] }"},
+ {"{}", nullptr, "{ Dom[0] -> [] }"}));
}
} // anonymous namespace
Index: lib/Transform/DeLICM.cpp
===================================================================
--- lib/Transform/DeLICM.cpp
+++ lib/Transform/DeLICM.cpp
@@ -400,6 +400,30 @@
return nullptr;
}
+/// Return whether @p Map maps to an unknown value.
+///
+/// @param { [] -> ValInst[] }
+bool isMapToUnknown(const isl::map &Map) {
+ auto Space = give(isl_space_range(isl_map_get_space(Map.keep())));
+ return !isl_map_has_tuple_id(Map.keep(), isl_dim_set) &&
+ !isl_space_is_wrapping(Space.keep()) &&
+ isl_map_dim(Map.keep(), isl_dim_out) == 0;
+}
+
+/// Return only the mappings that map to known values.
+///
+/// @param UMap { [] -> ValInst[] }
+///
+/// @return { [] -> ValInst[] }
+isl::union_map filterKnownValInst(const isl::union_map &UMap) {
+ auto Result = give(isl_union_map_empty(isl_union_map_get_space(UMap.keep())));
+ foreachElt(UMap, [=, &Result](isl::map Map) {
+ if (!isMapToUnknown(Map))
+ Result = give(isl_union_map_add_map(Result.take(), Map.take()));
+ });
+ return Result;
+}
+
/// Try to find a 'natural' extension of a mapped to elements outside its
/// domain.
///
@@ -756,19 +780,30 @@
}
// Does Proposed write at the same time as Existing already does (order of
- // writes is undefined)?
- auto ExistingWrittenDomain =
- isl::manage(isl_union_map_domain(Existing.Written.copy()));
- if (isl_union_set_is_disjoint(ExistingWrittenDomain.keep(),
- ProposedWrittenDomain.keep()) !=
- isl_bool_true) {
+ // writes is undefined)? Writing the same value is permitted.
+ auto BothWritten =
+ Existing.Written.domain().intersect(Proposed.Written.domain());
+ auto CommonWritten = filterKnownValInst(Existing.Written)
+ .intersect(filterKnownValInst(Proposed.Written))
+ .domain();
+
+ if (!BothWritten.is_subset(CommonWritten)) {
if (OS) {
- auto ConflictingWrites = give(isl_union_set_intersect(
- ExistingWrittenDomain.copy(), ProposedWrittenDomain.copy()));
+ auto Conflicting = BothWritten.subtract(CommonWritten);
+ auto ExistingConflictingWritten =
+ Existing.Written.intersect_domain(Conflicting);
+ auto ProposedConflictingWritten =
+ Proposed.Written.intersect_domain(Conflicting);
+
OS->indent(Indent) << "Proposed writes at the same time as an already "
"Existing write\n";
- OS->indent(Indent) << "Conflicting writes: " << ConflictingWrites
- << "\n";
+ OS->indent(Indent) << "Conflicting writes: " << Conflicting << "\n";
+ if (!ExistingConflictingWritten.is_empty())
+ OS->indent(Indent)
+ << "Exiting write: " << ExistingConflictingWritten << "\n";
+ if (!ProposedConflictingWritten.is_empty())
+ OS->indent(Indent)
+ << "Proposed write: " << ProposedConflictingWritten << "\n";
}
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32027.95148.patch
Type: text/x-patch
Size: 4015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170413/a12c6995/attachment.bin>
More information about the llvm-commits
mailing list