Re: [PATCH] [C FE] Fold trivial exprs that refer to const vars

2015-12-07 Thread Patrick Palka
On Mon, Dec 7, 2015 at 7:23 AM, Joseph Myers wrote: > On Mon, 7 Dec 2015, Patrick Palka wrote: > >> To fix this inconsistency, this patch calls decl_constant_value in >> c_fully fold after folding the given expression. > > The aim should be to eliminate decl_constant_value use here once all > fold

Re: [PATCH] [C FE] Fold trivial exprs that refer to const vars

2015-12-07 Thread Patrick Palka
On Mon, Dec 7, 2015 at 7:20 AM, Marek Polacek wrote: > On Sun, Dec 06, 2015 at 11:50:15PM -0500, Patrick Palka wrote: >> diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c >> index c554e17..ab0b37f 100644 >> --- a/gcc/c/c-fold.c >> +++ b/gcc/c/c-fold.c >> @@ -88,6 +88,7 @@ c_fully_fold (tree expr, bool

Re: [PATCH] [C FE] Fold trivial exprs that refer to const vars

2015-12-07 Thread Patrick Palka
On Sun, Dec 6, 2015 at 11:50 PM, Patrick Palka wrote: > There is a minor inconsistency in the folding behavior within the C > frontend. The C frontend does not currently fold the expression "x", > where x is a const int, yet the FE does fold the expression "x + 0". > > This happens because decl_c

Re: [PATCH] [C FE] Fold trivial exprs that refer to const vars

2015-12-07 Thread Joseph Myers
On Mon, 7 Dec 2015, Patrick Palka wrote: > To fix this inconsistency, this patch calls decl_constant_value in > c_fully fold after folding the given expression. The aim should be to eliminate decl_constant_value use here once all folding optimizations are also done on GIMPLE (and generally reduc

Re: [PATCH] [C FE] Fold trivial exprs that refer to const vars

2015-12-07 Thread Marek Polacek
On Sun, Dec 06, 2015 at 11:50:15PM -0500, Patrick Palka wrote: > diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c > index c554e17..ab0b37f 100644 > --- a/gcc/c/c-fold.c > +++ b/gcc/c/c-fold.c > @@ -88,6 +88,7 @@ c_fully_fold (tree expr, bool in_init, bool *maybe_const) > } >ret = c_fully_fold_

Re: [PATCH] [C FE] Fold trivial exprs that refer to const vars

2015-12-06 Thread Patrick Palka
On Sun, Dec 6, 2015 at 11:50 PM, Patrick Palka wrote: > There is a minor inconsistency in the folding behavior within the C > frontend. The C frontend does not currently fold the expression "x", > where x is a const int, yet the FE does fold the expression "x + 0". > > This happens because decl_c

[PATCH] [C FE] Fold trivial exprs that refer to const vars

2015-12-06 Thread Patrick Palka
There is a minor inconsistency in the folding behavior within the C frontend. The C frontend does not currently fold the expression "x", where x is a const int, yet the FE does fold the expression "x + 0". This happens because decl_constant_value is called in c_fully_fold only while recursing ove