From: Richard Guenther Date: Tue, 6 Mar 2012 13:16:50 +0000 (+0000) Subject: fold-const.c (build_fold_addr_expr_with_type_loc): Fold MEM_REF with constant pointer... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d8f56643c04e5c76d8e17ab97ba4c67654b488a1;p=gcc.git fold-const.c (build_fold_addr_expr_with_type_loc): Fold MEM_REF with constant pointer operand. 2012-03-06 Richard Guenther * fold-const.c (build_fold_addr_expr_with_type_loc): Fold MEM_REF with constant pointer operand. From-SVN: r184988 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3b88179294b..5ce9dc65c67 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2012-03-06 Richard Guenther + + * fold-const.c (build_fold_addr_expr_with_type_loc): Fold + MEM_REF with constant pointer operand. + 2012-03-06 Richard Guenther PR middle-end/52493 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 6492f116786..0f806752dd3 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7626,8 +7626,13 @@ build_fold_addr_expr_with_type_loc (location_t loc, tree t, tree ptrtype) t = build1_loc (loc, NOP_EXPR, ptrtype, t); } else if (TREE_CODE (t) == MEM_REF - && integer_zerop (TREE_OPERAND (t, 1))) + && integer_zerop (TREE_OPERAND (t, 1))) return TREE_OPERAND (t, 0); + else if (TREE_CODE (t) == MEM_REF + && TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST) + return fold_binary (POINTER_PLUS_EXPR, ptrtype, + TREE_OPERAND (t, 0), + convert_to_ptrofftype (TREE_OPERAND (t, 1))); else if (TREE_CODE (t) == VIEW_CONVERT_EXPR) { t = build_fold_addr_expr_loc (loc, TREE_OPERAND (t, 0));