This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[GSoC] type of an isl_ast_expr_id


I've tested Graphite with the ISL AST generator as the main code
generator and found out the following problem: in the current
implementation the gcc_expression_from_isl_ast_expr_id can return a
tree of a type, which doesn't correspond to the type chosen for
graphite expressions.

If we try, for example, to generate Gimple code from the following ISL AST:

if (J >= 1) {
  for (int c1 = 0; c1 < min(N, J); c1 += 1) {
    for (int c3 = 0; c3 < min(J, N); c3 += 1)
      S_10(c1, c3);
    for (int c3 = J + 1; c3 < N; c3 += 1)
      S_10(c1, c3);
  }
  for (int c1 = J + 1; c1 < N; c1 += 1) {
    for (int c3 = 0; c3 < J; c3 += 1)
      S_10(c1, c3);
    for (int c3 = J + 1; c3 < N; c3 += 1)
      S_10(c1, c3);
  }
} else
  for (int c1 = 1; c1 < N; c1 += 1)
    for (int c3 = 1; c3 < N; c3 += 1)
      S_10(c1, c3);

(It's generated from id-10.c)

we'll get the following error:

id-10.c: In function âfooâ:
id-10.c:4:1: internal compiler error: in fold_binary_loc, at fold-const.c:10692
 foo (int N, unsigned int J)
 ^
0x7cff3a fold_binary_loc(unsigned int, tree_code, tree_node*,
tree_node*, tree_node*)
/home/roman/sec_trunk/gcc/gcc/fold-const.c:10692
0x7d646a fold_build2_stat_loc(unsigned int, tree_code, tree_node*,
tree_node*, tree_node*)
/home/roman/sec_trunk/gcc/gcc/fold-const.c:15023
0xf010e8 nary_op_to_tree
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:290
0xf010e8 gcc_expression_from_isl_expr_op
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:317
0xf010e8 gcc_expression_from_isl_expression
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:364
0xf00f57 binary_op_to_tree
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:170
0xf00f57 gcc_expression_from_isl_expr_op
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:333
0xf00f57 gcc_expression_from_isl_expression
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:364
0xf018d0 graphite_create_new_loop_guard
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:523
0xf018d0 translate_isl_ast_node_for
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:558
0xf018d0 translate_isl_ast
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:704
0xf017b0 translate_isl_ast_node_block
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:646
0xf017b0 translate_isl_ast
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:715
0xf01702 translate_isl_ast_node_if
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:679
0xf01702 translate_isl_ast
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:708
0xf027d7 graphite_regenerate_ast_isl(scop*)
/home/roman/sec_trunk/gcc/gcc/graphite-isl-ast-to-gimple.c:893
0xefce8f graphite_transform_loops()
/home/roman/sec_trunk/gcc/gcc/graphite.c:304
0xefcf10 graphite_transforms
/home/roman/sec_trunk/gcc/gcc/graphite.c:333
0xefcf10 execute
/home/roman/sec_trunk/gcc/gcc/graphite.c:413

It is caused by difference in precisions of arguments in the min
expression. The attached patch may fix this.

I've also found out that pr35356-2.c is no longer suitable for
testing. The following CLooG AST

for (scat_1=0;scat_1<=min(k_6-1,n_5-1);scat_1++) {
  (scat_1);
}
if ((k_6 >= 0) && (n_5 >= k_6+1)) {
  (k_6);
}
for (scat_1=max(0,k_6+1);scat_1<=n_5-1;scat_1++) {
  (scat_1);
}

is generated from its source code

int a[100];

int
foo (int bar, int n, int k)
{
  int i;

  for (i = 0; i < n; i++)
    if (i == k)
      a[i] = 1;
    else
      a[i] = i;

  return a[bar];
}

The test checks that the dump file contains four MIN_EXPR and four MAX_EXPR

/* { dg-final { scan-tree-dump-times "MIN_EXPR\[^\\n\\r]*;" 4 "graphite" } } */
/* { dg-final { scan-tree-dump-times "MAX_EXPR\[^\\n\\r]*;" 4 "graphite" } } */

However, the ISL AST generated from this code

if (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 {
  if (k == 0)
    S_6(0);
  for (int c1 = max(k + 1, 0); c1 < n; c1 += 1)
    S_7(c1);
}

doesn't contain min expression at all.

Should we remove /* { dg-final { scan-tree-dump-times
"MIN_EXPR\[^\\n\\r]*;" 4 "graphite" } } */ from this test case?

P.S.: The other graphite tests (except vect-pr43423.c) are passed by
graphite in case we run it with the ISL AST generator.

--
                                   Cheers, Roman Gareev.

Attachment: ChangeLog_entry.txt
Description: Text document

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]