Code generation in Polly doesn't do a good job with disjunctions in ,
one statement will get materialized more than once which will increase code
size.
For example, for a do-while loop would be modeled like so: :: isl ast :: foo :: %do.body---%do.end [p_0] -> { : -2147483648 <= p_0 <= 2147483647 } { domain: "[p_0] -> { Stmt0[i0] : 0 <= i0 < p_0; Stmt0[0] : p_0 <= 0 }", child: { schedule: "[p_0] -> [{ Stmt0[i0] -> [(i0)] }]" } } if (1 && 0 == (p_0 >= 268435457 || p_0 <= -1)) { #pragma simd #pragma known-parallel for (int c0 = 0; c0 < p_0; c0 += 1) Stmt0(c0); if (p_0 <= 0) Stmt0(0); <---- will be rematerialized. } else { /* original code */ } In the resulting AST There is a separate instance for the 0 case (of p_0) and different one for the non zero case. By pruning the domain set to ignore singletons we can generate a contiguous set, we can do that by injecting the assumption that the loop trip count is always > 0 to generate a domain (and corresponding AST) that looks like so: :: isl ast :: foo :: %do.body---%do.end [p_0] -> { : -2147483648 <= p_0 <= 2147483647 } { domain: "[p_0] -> { Stmt0[i0] : 0 <= i0 < p_0 }", child: { schedule: "[p_0] -> [{ Stmt0[i0] -> [(i0)] }]" } } if (p_0 >= 1 && 0 == (p_0 >= 268435457 || p_0 <= -1)) --> added a condition for P_0 > 1 #pragma simd #pragma known-parallel for (int c0 = 0; c0 < p_0; c0 += 1) Stmt0(c0); else { /* original code */ }
This patch received intensive testing and showed considerable code size saving when used to build android.
This patch will have significant code size saving by eliminating excessive versioning in the AST for the values
of parameters. Look at the full AST listing for the test case test/ScopDetect/model-dowhile.ll
Can you use something more descriptive?