PATCH: fold BIT_AND_EXPR's with ADDR_EXPR operands

Ollie Wild
Tue Sep 11 06:13:00 GMT 2007

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.

Tested with a full bootstrap and testsuite on i686-pc-linux-gnu.


2007-09-10  Ollie Wild  <>

      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  <>

      gcc.dg/fold-bitand-1.c: New test.
      gcc.dg/fold-bitand-2.c: New test.
      gcc.dg/fold-bitand-3.c: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fold-bitand.patch
Type: text/x-patch
Size: 5643 bytes
Desc: not available
URL: <>

More information about the Gcc-patches mailing list