> Blindly converting type sizes is not a good idea and may be problematic when
> we switch to smaller types. As we can obviously only improve this when we
> have the appropriate support in isl, I think the attached patch is fine.
> However, please add a fixme that states that this should
> be looked at again at the moment when we get isl support to derive the
> optimal types.

I've attached a patch, which contains the fixme.

> Please have a look at the original bug report:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35356
>
> The isl ast generator should produce something like:
>
>   for (i = 0; i < min (n, k); i++)
>      a[i] = i;
>   if (k >= 0 && k < n)
>      a[k] = 1;
>   for (i = max(k+1,0); i < n; i++)
>      a[i] = i;
>
> CLooG does not generate optimal code either, but the code generated by isl
> is a regression compared to CLooG.
>
> Can you generate an isl_codegen input for this test case and verify that the
> latest public version of isl does not generate this optimal code either. If
> it does not, please report this as an optimization bug to the isl mailing
> list.
>
> After you got feedback, I think it is OK to disable this test and to
> add a FIXME explaining why this test is disabled and if we can expect a fix
> in later versions of isl.

I've generated the code using the isl-0.13

if (n >= k + 1) {
  for (int c1 = 0; c1 < n; c1 += 1) {
    if (c1 >= k + 1) {
      S_7(c1);
    } else if (k >= c1 + 1) {
      S_7(c1);
    } else
      S_6(k);
  }
} else
  for (int c1 = 0; c1 < n; c1 += 1)
    S_7(c1);

If I'm not mistaken it's also a regression compared to ClooG and it's
better to report this to the isl mailing list.

> What is the problem with this last test case?

It is related to checking for the loop parallelism, which is not yet
implemented in the current version of graphite-isl-ast-to-gimple.c.

--
                                   Cheers, Roman Gareev.
2014-07-30  Roman Gareev  <gareevro...@gmail.com>

[gcc/]

        * graphite-isl-ast-to-gimple.c:
        (gcc_expression_from_isl_ast_expr_id): Add calling of fold_convert.
        (gcc_expression_from_isl_expression): Pass type to
        gcc_expression_from_isl_ast_expr_id.
Index: gcc/graphite-isl-ast-to-gimple.c
===================================================================
--- gcc/graphite-isl-ast-to-gimple.c    (revision 213109)
+++ gcc/graphite-isl-ast-to-gimple.c    (working copy)
@@ -122,10 +122,14 @@
                                    ivs_params &ip);
 
 /* Return the tree variable that corresponds to the given isl ast identifier
- expression (an isl_ast_expr of type isl_ast_expr_id).  */
+   expression (an isl_ast_expr of type isl_ast_expr_id).
 
+   FIXME: We should replace blind conversation of id's type with derivation
+   of the optimal type when we get the corresponding isl support.  */
+
 static tree
-gcc_expression_from_isl_ast_expr_id (__isl_keep isl_ast_expr *expr_id,
+gcc_expression_from_isl_ast_expr_id (tree type,
+                                    __isl_keep isl_ast_expr *expr_id,
                                     ivs_params &ip)
 {
   gcc_assert (isl_ast_expr_get_type (expr_id) == isl_ast_expr_id);
@@ -136,7 +140,7 @@
   gcc_assert (res != ip.end () &&
               "Could not map isl_id to tree expression");
   isl_ast_expr_free (expr_id);
-  return res->second;
+  return fold_convert (type, res->second);
 }
 
 /* Converts an isl_ast_expr_int expression E to a GCC expression tree of
@@ -351,7 +355,7 @@
   switch (isl_ast_expr_get_type (expr))
     {
     case isl_ast_expr_id:
-      return gcc_expression_from_isl_ast_expr_id (expr, ip);
+      return gcc_expression_from_isl_ast_expr_id (type, expr, ip);
 
     case isl_ast_expr_int:
       return gcc_expression_from_isl_expr_int (type, expr);

Reply via email to