summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorvries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-31 09:33:25 +0000
committervries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-31 09:33:25 +0000
commit5569a36f8123867c2ad6efd4effebc55ea778af7 (patch)
tree8d3d2131443e37af6aa9321e23fd5a717c4b411f /gcc/fold-const.c
parente83a804f79584275f87695b8a8e3c2e841016c91 (diff)
downloadgcc-5569a36f8123867c2ad6efd4effebc55ea778af7.tar.gz
Tune pointer-plus folding
2015-10-31 Tom de Vries <tom@codesourcery.com> * fold-const.c (fold_unary_loc): Tune POINTER_PLUS_EXPR folding. * gfortran.dg/assumed_type_2.f90: Update test. * gfortran.dg/no_arg_check_2.f90: Same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229621 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index b9168f331ed..197ccfddddb 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -7755,14 +7755,12 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
}
}
- /* Convert (T1)(X p+ Y) into ((T1)X p+ Y), for pointer type,
- when one of the new casts will fold away. Conservatively we assume
- that this happens when X or Y is NOP_EXPR or Y is INTEGER_CST. */
+ /* Convert (T1)(X p+ Y) into ((T1)X p+ Y), for pointer type, when the new
+ cast (T1)X will fold away. We assume that this happens when X itself
+ is a cast. */
if (POINTER_TYPE_P (type)
&& TREE_CODE (arg0) == POINTER_PLUS_EXPR
- && (TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
- || TREE_CODE (TREE_OPERAND (arg0, 0)) == NOP_EXPR
- || TREE_CODE (TREE_OPERAND (arg0, 1)) == NOP_EXPR))
+ && CONVERT_EXPR_P (TREE_OPERAND (arg0, 0)))
{
tree arg00 = TREE_OPERAND (arg0, 0);
tree arg01 = TREE_OPERAND (arg0, 1);