[polly] r235860 - Remove implementation of getNumberOfIterations from header [NFC]
Tobias Grosser
tobias at grosser.es
Mon Apr 27 03:38:45 PDT 2015
Author: grosser
Date: Mon Apr 27 05:38:45 2015
New Revision: 235860
URL: http://llvm.org/viewvc/llvm-project?rev=235860&view=rev
Log:
Remove implementation of getNumberOfIterations from header [NFC]
We moved this implementation into the header file to share it between
the CLooG and isl code generator. As the CLooG code generator was dropped,
the implementation can be folded back into the .cpp file.
No functional change intended.
Modified:
polly/trunk/include/polly/CodeGen/CodeGeneration.h
polly/trunk/lib/CodeGen/IslCodeGeneration.cpp
Modified: polly/trunk/include/polly/CodeGen/CodeGeneration.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/CodeGeneration.h?rev=235860&r1=235859&r2=235860&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/CodeGeneration.h (original)
+++ polly/trunk/include/polly/CodeGen/CodeGeneration.h Mon Apr 27 05:38:45 2015
@@ -30,48 +30,6 @@ extern CodeGenChoice PollyCodeGenChoice;
/// @brief Flag to turn on/off annotation of alias scopes.
extern bool PollyAnnotateAliasScopes;
-
-static inline int getNumberOfIterations(__isl_take isl_set *Domain) {
- int Dim = isl_set_dim(Domain, isl_dim_set);
-
- // Calculate a map similar to the identity map, but with the last input
- // and output dimension not related.
- // [i0, i1, i2, i3] -> [i0, i1, i2, o0]
- isl_space *Space = isl_set_get_space(Domain);
- Space = isl_space_drop_dims(Space, isl_dim_out, Dim - 1, 1);
- Space = isl_space_map_from_set(Space);
- isl_map *Identity = isl_map_identity(Space);
- Identity = isl_map_add_dims(Identity, isl_dim_in, 1);
- Identity = isl_map_add_dims(Identity, isl_dim_out, 1);
-
- Domain = isl_set_reset_tuple_id(Domain);
-
- isl_map *Map =
- isl_map_from_domain_and_range(isl_set_copy(Domain), isl_set_copy(Domain));
- isl_set_free(Domain);
- Map = isl_map_intersect(Map, Identity);
-
- isl_map *LexMax = isl_map_lexmax(isl_map_copy(Map));
- isl_map *LexMin = isl_map_lexmin(Map);
- isl_map *Sub = isl_map_sum(LexMax, isl_map_neg(LexMin));
-
- isl_set *Elements = isl_map_range(Sub);
-
- if (!isl_set_is_singleton(Elements)) {
- isl_set_free(Elements);
- return -1;
- }
-
- isl_point *P = isl_set_sample_point(Elements);
-
- isl_val *V;
- V = isl_point_get_coordinate_val(P, isl_dim_set, Dim - 1);
- int NumberIterations = isl_val_get_num_si(V);
- isl_val_free(V);
- isl_point_free(P);
-
- return NumberIterations;
-}
}
#endif // POLLY_CODEGENERATION_H
Modified: polly/trunk/lib/CodeGen/IslCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslCodeGeneration.cpp?rev=235860&r1=235859&r2=235860&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/IslCodeGeneration.cpp Mon Apr 27 05:38:45 2015
@@ -297,10 +297,46 @@ IslNodeBuilder::getUpperBound(__isl_keep
unsigned IslNodeBuilder::getNumberOfIterations(__isl_keep isl_ast_node *For) {
isl_union_map *Schedule = IslAstInfo::getSchedule(For);
isl_set *LoopDomain = isl_set_from_union_set(isl_union_map_range(Schedule));
- int NumberOfIterations = polly::getNumberOfIterations(LoopDomain);
- if (NumberOfIterations == -1)
+ int Dim = isl_set_dim(LoopDomain, isl_dim_set);
+
+ // Calculate a map similar to the identity map, but with the last input
+ // and output dimension not related.
+ // [i0, i1, i2, i3] -> [i0, i1, i2, o0]
+ isl_space *Space = isl_set_get_space(LoopDomain);
+ Space = isl_space_drop_dims(Space, isl_dim_out, Dim - 1, 1);
+ Space = isl_space_map_from_set(Space);
+ isl_map *Identity = isl_map_identity(Space);
+ Identity = isl_map_add_dims(Identity, isl_dim_in, 1);
+ Identity = isl_map_add_dims(Identity, isl_dim_out, 1);
+
+ LoopDomain = isl_set_reset_tuple_id(LoopDomain);
+
+ isl_map *Map = isl_map_from_domain_and_range(isl_set_copy(LoopDomain),
+ isl_set_copy(LoopDomain));
+ isl_set_free(LoopDomain);
+ Map = isl_map_intersect(Map, Identity);
+
+ isl_map *LexMax = isl_map_lexmax(isl_map_copy(Map));
+ isl_map *LexMin = isl_map_lexmin(Map);
+ isl_map *Sub = isl_map_sum(LexMax, isl_map_neg(LexMin));
+
+ isl_set *Elements = isl_map_range(Sub);
+
+ if (!isl_set_is_singleton(Elements)) {
+ isl_set_free(Elements);
+ return -1;
+ }
+
+ isl_point *P = isl_set_sample_point(Elements);
+
+ isl_val *V;
+ V = isl_point_get_coordinate_val(P, isl_dim_set, Dim - 1);
+ int NumberIterations = isl_val_get_num_si(V);
+ isl_val_free(V);
+ isl_point_free(P);
+ if (NumberIterations == -1)
return -1;
- return NumberOfIterations + 1;
+ return NumberIterations + 1;
}
struct FindValuesUser {
More information about the llvm-commits
mailing list