PATCH: fold BIT_AND_EXPR's with ADDR_EXPR operands

Richard Guenther richard.guenther@gmail.com
Tue Sep 11 09:56:00 GMT 2007


On 9/11/07, Ollie Wild <aaw@google.com> wrote:
> This patch adds support for folding BIT_AND_EXPR's with pointer
> operands derived from ADDR_EXPR's.
>
> If a BIT_AND_EXPR contains (a) a pointer operand derived from an
> ADDR_EXPR and (b) an INTEGER_CST operand whose value is smaller than
> the alignment of the addressed object, then it is possible to fold the
> expression into a single INTEGER_CST.  This is important to the C++
> front end because (on some architectures) this construct appears in
> pointers to non-virtual member functions.  This patch allows
> dereferencing of these objects to be simplified into simple function
> calls where the referenced member function is known.

Can you consolidate your get_lvalue_alignment with
builtins.c:get_pointer_alignment?
It seems to have more sophisticated handling of ADDR_EXPRs.

Thanks,
Richard.

>
> Tested with a full bootstrap and testsuite on i686-pc-linux-gnu.
>
> Ollie
>
>
> 2007-09-10  Ollie Wild  <aaw@google.com>
>
>       fold-const.c (fold_binary): Fold BIT_AND_EXPR's with a pointer operand.
>       (get_pointer_modulus_and_residue): New function.
>       (get_lvalue_alignment): New function.
>
> 2007-09-10  Ollie Wild  <aaw@google.com>
>
>       gcc.dg/fold-bitand-1.c: New test.
>       gcc.dg/fold-bitand-2.c: New test.
>       gcc.dg/fold-bitand-3.c: New test.
>
>



More information about the Gcc-patches mailing list