[PTR-PLUS] Fix 6 regressions due to missing optimization of &a + CONST into &a[CONST/SIZE]

Andrew_Pinski@PlayStation.Sony.Com Andrew_Pinski@PlayStation.Sony.Com
Wed May 2 23:06:00 GMT 2007


Hi,
  The problem here is that maybe_fold_stmt_indirect was not being called 
for POINTER_PLUS_EXPRs which caused &a + CONST not being turned into 
&a[CONST/SIZE].  This patch also cleans up the code so it does not call 
maybe_fold_stmt_indirect for PLUS_EXPR or MINUS_EXPR and the need for 
subtraction as it is always addition.  Also it was time to clean up 
try_move_mult_to_index for POINTER_PLUS_EXPR to force it only be called 
for POINTER_PLUS_EXPR, this allowed to remove some code.


Committed to the branch after a bootstrap/test on i686-linux-gnu with no 
regressions.

Thanks,
Andrew Pinski

ChangeLog:

        * fold-const.c (try_move_mult_to_index): Remove code argument
        and replace     all uses with PLUS_EXPR.
        (fold_binary <case POINTER_PLUS_EXR>): Remove code argument.
        (fold_binary <case PLUS_EXPR>): Don't call try_move_mult_to_index.
        (fold_binary <case MINUS_EXPR>): Likewise.
        * tree-ssa-ccp.c (maybe_fold_stmt_indirect): Remove subtraction
        case as it is always addition now.
        (fold_stmt_r): Don't handle PLUS_EXPR/MINUS_EXPR specially.
        Handle POINTER_PLUS_EXPR like PLUS_EXPR was handled before.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fixfold_stmt.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070502/9b8be9f5/attachment.txt>


More information about the Gcc-patches mailing list