This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] More CCP fixes [patch]
On Sun, 2002-08-11 at 18:30, Jason Merrill wrote:
> On Sun, 11 Aug 2002 18:07:27 -0400, Diego Novillo <dnovillo@redhat.com> wrote:
>
> > On Sun, 11 Aug 2002, Diego Novillo wrote:
> >
> >> 1- Constant propagation of bitfield references. This is a
> >> simplification problem in execute/bf-sign-1:
> >>
> >> struct {
> >> signed int s:3;
> >> unsigned int u:3;
> >> int i:3;
> >> } x = {-1, -1, -1};
> >>
> >> if (x.u != 7)
> >>
> >> The above is simplified into:
> >>
> >> x = {.s=-1, .u=-1, .i=-1};
> >> T.1 = (int)x.u;
> >> if (T.1 != 7)
> >>
> >> I think CCP should use the bitfield size to determine the
> >> value for T.1. Or maybe the simplifier should expose the
> >> bitfield size when simplifying. I'm still not sure.
> >>
> > To answer my own question. This should be exposed by the
> > simplifier. Otherwise, we are forcing the optimizer to know
> > about C semantics.
>
> Shouldn't the optimizer just be able to see that x.u was initialized to -1,
> and not care about its size?
>
The problem here is that x.u is a 3-bit unsigned int. Setting it to -1
is really setting it to 7 (when expanded into an int).
CCP did propagate a -1 value. That causes the regression.
Diego.