From 6664e41e591d16225bbed95a41d43c44464894fd Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Sat, 31 Oct 2015 09:33:25 +0000 Subject: [PATCH] Tune pointer-plus folding 2015-10-31 Tom de Vries * 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. From-SVN: r229621 --- gcc/ChangeLog | 4 ++++ gcc/fold-const.c | 10 ++++------ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/assumed_type_2.f90 | 2 +- gcc/testsuite/gfortran.dg/no_arg_check_2.f90 | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7e4fa20a4cd..48cd3f80d43 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2015-10-31 Tom de Vries + + * fold-const.c (fold_unary_loc): Tune POINTER_PLUS_EXPR folding. + 2015-10-31 Tom de Vries * tree-ssa-structalias.c (intra_create_variable_infos): Don't expect 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2ec795cda2a..85dff2ef2f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-10-31 Tom de Vries + + * gfortran.dg/assumed_type_2.f90: Update test. + * gfortran.dg/no_arg_check_2.f90: Same. + 2015-10-30 Cesar Philippidis * gfortran.dg/gomp/intentin1.f90: Adjust copyprivate warning. diff --git a/gcc/testsuite/gfortran.dg/assumed_type_2.f90 b/gcc/testsuite/gfortran.dg/assumed_type_2.f90 index ec51b8bcaa8..f1a20747884 100644 --- a/gcc/testsuite/gfortran.dg/assumed_type_2.f90 +++ b/gcc/testsuite/gfortran.dg/assumed_type_2.f90 @@ -155,7 +155,7 @@ end ! { dg-final { scan-tree-dump-times "sub_scalar .&\\(.\\(struct t2.0:. . restrict\\) array_t2_alloc.data" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_scalar .&\\(.\\(struct t3.0:. .\\) array_t3_ptr.data" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) array_class_t1_alloc._data.data" 1 "original" } } -! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) array_class_t1_ptr._data.dat" 1 "original" } }a +! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) \\(array_class_t1_ptr._data.dat" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_array_assumed \\(D" 3 "original" } } ! { dg-final { scan-tree-dump-times " = _gfortran_internal_pack \\(&parm" 1 "original" } } diff --git a/gcc/testsuite/gfortran.dg/no_arg_check_2.f90 b/gcc/testsuite/gfortran.dg/no_arg_check_2.f90 index 3645dedeb21..b3fb4685efe 100644 --- a/gcc/testsuite/gfortran.dg/no_arg_check_2.f90 +++ b/gcc/testsuite/gfortran.dg/no_arg_check_2.f90 @@ -137,7 +137,7 @@ end ! { dg-final { scan-tree-dump-times "sub_scalar .&\\(.\\(struct t2.0:. . restrict\\) array_t2_alloc.data" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_scalar .&\\(.\\(struct t3.0:. .\\) array_t3_ptr.data" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) array_class_t1_alloc._data.data" 1 "original" } } -! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) array_class_t1_ptr._data.dat" 1 "original" } }a +! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) \\(array_class_t1_ptr._data.dat" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_array_assumed \\(D" 3 "original" } } ! { dg-final { scan-tree-dump-times " = _gfortran_internal_pack \\(&parm" 1 "original" } } -- 2.30.2