This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: generic bug in fixed-point constant folding
- From: "Fu, Chao-Ying" <fu at mips dot com>
- To: "Sean D'Epagnier" <geckosenator at gmail dot com>, <gcc at gcc dot gnu dot org>
- Date: Tue, 17 Mar 2009 11:45:47 -0700
- Subject: RE: generic bug in fixed-point constant folding
Sean D'Epagnier wrote:
>
> I think I found a generic problem for fixed point constant folding.
>
> In fold-const.c:11872 gcc tries to apply:
> /* Transform (x >> c) << c into x & (-1<<c), or transform (x <<
> c) >> c
> into x & ((unsigned)-1 >> c) for unsigned types. */
>
> I attached a simple patch which fixes the problem by not applying this
> optimization to fixed point types. I would like to have this
> optimization because it is possible.. but the problem is fixed-point
> types do not support bitwise operations like & | ^ ~.. so without
> supporting these somehow internally but not allowing the user to have
> them, this can't take place.
>
> I am open to other suggestions. For future reference should this be
> posted as a bug report? It seems simple enough that it could be
> included right away.. but I feel like if it's a bug report no one will
> notice since fixed-point support is not widely used.
>
> Sean
>
Thanks for finding this bug and fixing it! I think you should send your
patch to gcc-patches@gcc.gnu.org, and check in this patch to mainline and 4.3
if possible.
Regards,
Chao-ying