--- Paolo Bonzini <[EMAIL PROTECTED]> wrote:
> Etienne Lorrain wrote:
> > Hello,
> >
> > You really do not want to get a correction for:
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23631
> > before release?
> >
> > I checked again with 4.0.2 20050917, and nothing
> > has changed since:
> > http://gcc.gnu.org/ml/gcc/2005-09/msg00251.html
>
> Etienne, does the patch at
> http://gcc.gnu.org/ml/gcc-patches/2005-08/msg01747.html work for you?
>
> Paolo
>
I applied the patch by hand (not working with CVS) and it
does _not_ solve the problem.
To reproduce, compile:
int sub (int i)
{
int array[1000000] = { 0 };
sub2 (&array[i]);
}
with
~/projet/toolchain/bin/gcc -c -Os tmp.c
and type:
$ size tmp.o
text data bss dec hex filename
4000052 0 0 4000052 3d0934 tmp.o
too big text size...
The exact patch I have here is:
--- gcc-4.0.2-20050917/gcc/expr.c 2005-09-10 03:03:28.000000000 +0200
+++ gcc-4.0.2-20050917-new/gcc/expr.c 2005-09-19 14:39:41.206416416 +0200
@@ -6390,6 +6390,23 @@
return ret;
}
+/* Return 1 if EXP contains all zeros. */
+
+static int
+all_zeros_p (tree exp)
+{
+ if (TREE_CODE (exp) == CONSTRUCTOR)
+ {
+ HOST_WIDE_INT nz_elts, nc_elts, count;
+ bool must_clear;
+
+ categorize_ctor_elements (exp, &nz_elts, &nc_elts, &count,
&must_clear);
+ return nz_elts == 0;
+ }
+
+ return initializer_zerop (exp);
+}
+
static rtx
expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
enum expand_modifier modifier, rtx *alt_rtl)
@@ -6737,8 +6754,21 @@
return const0_rtx;
}
-
- /* All elts simple constants => refer to a constant in memory. But
+ /* Try to avoid creating a temporary at all. This is possible
+ if we can construct with a single memset, which store_constructor
+ knows how to do.
+ FIXME: exchange all_zeros_p for something that allows all
+ [0..255] initializers. */
+ else if (TREE_STATIC (exp)
+ && !TREE_ADDRESSABLE (exp)
+ && target != 0 && mode == BLKmode
+ && all_zeros_p (exp))
+ {
+ store_constructor (exp, target, 0, int_expr_size (exp));
+ return target;
+ }
+
+ /* All elts simple constants => refer to a constant in memory. But
if this is a non-BLKmode mode, let it store a field at a time
since that should make a CONST_INT or CONST_DOUBLE when we
fold. Likewise, if we have a target we can use, it is best to
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com