From: Jakub Jelinek Date: Thu, 7 Jul 2011 12:49:17 +0000 (+0200) Subject: re PR middle-end/49640 (Internal compiler in C99 code (using variable-length arrays... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=19c44640ebdf27fd4f6a073af4141f2a37283b9b;p=gcc.git re PR middle-end/49640 (Internal compiler in C99 code (using variable-length arrays) and OpenMP) PR middle-end/49640 * gimplify.c (gimplify_compound_lval): For last 2 ARRAY_*REF operands and last COMPONENT_REF operand call gimplify_expr on it if non-NULL. * gcc.dg/gomp/pr49640.c: New test. From-SVN: r175967 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 22e3269a3c5..a203616640b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-07-07 Jakub Jelinek + + PR middle-end/49640 + * gimplify.c (gimplify_compound_lval): For last 2 ARRAY_*REF + operands and last COMPONENT_REF operand call gimplify_expr on it + if non-NULL. + 2011-07-07 Rainer Orth PR libmudflap/49550 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index bc6d32179a6..4ff7e933834 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2010,8 +2010,14 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, ret = MIN (ret, tret); } } + else + { + tret = gimplify_expr (&TREE_OPERAND (t, 2), pre_p, post_p, + is_gimple_reg, fb_rvalue); + ret = MIN (ret, tret); + } - if (!TREE_OPERAND (t, 3)) + if (TREE_OPERAND (t, 3) == NULL_TREE) { tree elmt_type = TREE_TYPE (TREE_TYPE (TREE_OPERAND (t, 0))); tree elmt_size = unshare_expr (array_ref_element_size (t)); @@ -2031,11 +2037,17 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, ret = MIN (ret, tret); } } + else + { + tret = gimplify_expr (&TREE_OPERAND (t, 3), pre_p, post_p, + is_gimple_reg, fb_rvalue); + ret = MIN (ret, tret); + } } else if (TREE_CODE (t) == COMPONENT_REF) { /* Set the field offset into T and gimplify it. */ - if (!TREE_OPERAND (t, 2)) + if (TREE_OPERAND (t, 2) == NULL_TREE) { tree offset = unshare_expr (component_ref_field_offset (t)); tree field = TREE_OPERAND (t, 1); @@ -2054,6 +2066,12 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, ret = MIN (ret, tret); } } + else + { + tret = gimplify_expr (&TREE_OPERAND (t, 2), pre_p, post_p, + is_gimple_reg, fb_rvalue); + ret = MIN (ret, tret); + } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2c390b4c3d6..e54290995d8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-07-07 Jakub Jelinek + + PR middle-end/49640 + * gcc.dg/gomp/pr49640.c: New test. + 2011-07-07 Richard Guenther * gcc.dg/graphite/pr37485.c: Add -floop-block. diff --git a/gcc/testsuite/gcc.dg/gomp/pr49640.c b/gcc/testsuite/gcc.dg/gomp/pr49640.c new file mode 100644 index 00000000000..6e0973864a3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr49640.c @@ -0,0 +1,29 @@ +/* PR middle-end/49640 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=gnu99 -fopenmp" } */ + +void +foo (int N, int M, int K, int P, int Q, int R, int i, int j, int k, + unsigned char x[P][Q][R], int y[N][M][K]) +{ + int ii, jj, kk; + +#pragma omp parallel for private(ii,jj,kk) + for (ii = 0; ii < P; ++ii) + for (jj = 0; jj < Q; ++jj) + for (kk = 0; kk < R; ++kk) + y[i + ii][j + jj][k + kk] = x[ii][jj][kk]; +} + +void +bar (int N, int M, int K, int P, int Q, int R, int i, int j, int k, + unsigned char x[P][Q][R], float y[N][M][K], float factor, float zero) +{ + int ii, jj, kk; + +#pragma omp parallel for private(ii,jj,kk) + for (ii = 0; ii < P; ++ii) + for (jj = 0; jj < Q; ++jj) + for (kk = 0; kk < R; ++kk) + y[i + ii][j + jj][k + kk] = factor * x[ii][jj][kk] + zero; +}