Pointer Plus Expression
- GCC currently uses a cast and then a plus expression for pointer arithmetic at the tree level. This causes the optimizers not to figure out what is the base of a pointer and what is the offset. This project adds a tree for pointer addition, taking a pointer type as the first operand and an integer type as the second operand (compatiable with sizetype).
Personnel
- Andrew Pinski of Sony Computer Entertainment
- Zdenek Dvorak of SUSE
Delivery Date
- This infrastructure change will be ready by May 21st 2007.
- status as of May 26st 2007:
- bootstraps/builds: powerpc64-linux-gnu, spu-elf, i686-linux-gnu, x86_64-linux-gnu, powerpc-darwin, sh4-unknown-linux-gnu
- two testsuite regressions due to forwprop being better and data-ref needing help
The fix for PR 32075 just needs testing
- SPEC results look ok, gzip regression might need a look into
- tramp3d compile time and runtime same or slightly faster than the mainline
- compiling at -O0 -g for a couple of testcase slightly faster
Benefits
The optimizers will be less confused at what is the base and offset of the pointer addition. This also reduces in some cases the memory usage of the compiler because there are less casts. An example of where aliasing analysis gets confused is gcc.dg/vect/vect-106.c where on the branch we are now able to vectorize a loop using two malloc'd memories. PR18412 and PR29708 are examples of bug reports which get fixed by pointer plus.
Dependencies
- None.
Modifications Required
- All of the front-ends need to produce POINTER_PLUS_EXPR instead of a PLUS_EXPR. All of the tree optimizers need to be updated to look at POINTER_PLUS_EXPR instead of sometimes PLUS_EXPR. All the back-end's gimplify_va_args need to be updated to use POINTER_PLUS_EXPR instead of a PLUS_EXPR.