This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

  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 

Andrew Pinski


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

Attachment: fixfold_stmt.diff.txt
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]