aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2010-02-28 17:16:22 +0100
committerTobias Burnus <burnus@gcc.gnu.org>2010-02-28 17:16:22 +0100
commitdfd65514fec4a88783219dca811b2db1adce5f69 (patch)
treea2c90c86c17c13464bf00f049446cd0aa120226f /gcc
parentaad16db9136676b6caac26ff55d0d79cce54cecd (diff)
downloadgcc-dfd65514fec4a88783219dca811b2db1adce5f69.zip
gcc-dfd65514fec4a88783219dca811b2db1adce5f69.tar.gz
gcc-dfd65514fec4a88783219dca811b2db1adce5f69.tar.bz2
re PR fortran/43205 (-finit-local-zero and -fno-automatic used together with large 2-dim variables take too long to compile)
2010-02-28 Tobias Burnus <burnus@net-b.de> PR fortran/43205 * trans-expr.c (is_zero_initializer_p): Move up in the file. (gfc_conv_initializer): Handle zero initializer as special case. From-SVN: r157123
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/trans-expr.c75
2 files changed, 46 insertions, 35 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index e5d7224..88fe30e 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2010-02-28 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/43205
+ * trans-expr.c (is_zero_initializer_p): Move up in the file.
+ (gfc_conv_initializer): Handle zero initializer as special case.
+
2010-02-27 Tobias Burnus <burnus@net-b.de>
PR fortran/43185
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index ecb577a..abc2a24 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -3910,6 +3910,43 @@ gfc_conv_function_expr (gfc_se * se, gfc_expr * expr)
}
+/* Determine whether the given EXPR_CONSTANT is a zero initializer. */
+
+static bool
+is_zero_initializer_p (gfc_expr * expr)
+{
+ if (expr->expr_type != EXPR_CONSTANT)
+ return false;
+
+ /* We ignore constants with prescribed memory representations for now. */
+ if (expr->representation.string)
+ return false;
+
+ switch (expr->ts.type)
+ {
+ case BT_INTEGER:
+ return mpz_cmp_si (expr->value.integer, 0) == 0;
+
+ case BT_REAL:
+ return mpfr_zero_p (expr->value.real)
+ && MPFR_SIGN (expr->value.real) >= 0;
+
+ case BT_LOGICAL:
+ return expr->value.logical == 0;
+
+ case BT_COMPLEX:
+ return mpfr_zero_p (mpc_realref (expr->value.complex))
+ && MPFR_SIGN (mpc_realref (expr->value.complex)) >= 0
+ && mpfr_zero_p (mpc_imagref (expr->value.complex))
+ && MPFR_SIGN (mpc_imagref (expr->value.complex)) >= 0;
+
+ default:
+ break;
+ }
+ return false;
+}
+
+
static void
gfc_conv_array_constructor_expr (gfc_se * se, gfc_expr * expr)
{
@@ -3960,6 +3997,9 @@ gfc_conv_initializer (gfc_expr * expr, gfc_typespec * ts, tree type,
/* Arrays need special handling. */
if (pointer)
return gfc_build_null_descriptor (type);
+ /* Special case assigning an array to zero. */
+ else if (is_zero_initializer_p (expr))
+ return build_constructor (type, NULL);
else
return gfc_conv_array_initializer (type, expr);
}
@@ -5061,41 +5101,6 @@ gfc_trans_arrayfunc_assign (gfc_expr * expr1, gfc_expr * expr2)
return gfc_finish_block (&se.pre);
}
-/* Determine whether the given EXPR_CONSTANT is a zero initializer. */
-
-static bool
-is_zero_initializer_p (gfc_expr * expr)
-{
- if (expr->expr_type != EXPR_CONSTANT)
- return false;
-
- /* We ignore constants with prescribed memory representations for now. */
- if (expr->representation.string)
- return false;
-
- switch (expr->ts.type)
- {
- case BT_INTEGER:
- return mpz_cmp_si (expr->value.integer, 0) == 0;
-
- case BT_REAL:
- return mpfr_zero_p (expr->value.real)
- && MPFR_SIGN (expr->value.real) >= 0;
-
- case BT_LOGICAL:
- return expr->value.logical == 0;
-
- case BT_COMPLEX:
- return mpfr_zero_p (mpc_realref (expr->value.complex))
- && MPFR_SIGN (mpc_realref (expr->value.complex)) >= 0
- && mpfr_zero_p (mpc_imagref (expr->value.complex))
- && MPFR_SIGN (mpc_imagref (expr->value.complex)) >= 0;
-
- default:
- break;
- }
- return false;
-}
/* Try to efficiently translate array(:) = 0. Return NULL if this
can't be done. */