From: Richard Biener Date: Fri, 13 Jul 2018 11:25:38 +0000 (+0000) Subject: re PR middle-end/85974 (Failure to optimize difference of two pointers into a compile... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=67fccea48da5b2a7a62f9b08acc01b254ab4c1a5;p=gcc.git re PR middle-end/85974 (Failure to optimize difference of two pointers into a compile time constant) 2018-07-13 Richard Biener PR middle-end/85974 * match.pd (addr1 - addr2): Allow either of the operand to have a conversion. * gcc.c-torture/compile/930326-1.c: Adjust to cover widening. From-SVN: r262632 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3f70e46d193..2ca3333161c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-07-13 Richard Biener + + PR middle-end/85974 + * match.pd (addr1 - addr2): Allow either of the operand to + have a conversion. + 2018-07-13 Tom de Vries * tree-inline.c (remap_ssa_name): Save and reuse debug exprs generated diff --git a/gcc/match.pd b/gcc/match.pd index 1a8ad446585..730bbabb593 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1673,14 +1673,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (ptr_difference_const (@0, @1, &diff)) { build_int_cst_type (type, diff); })))) (simplify - (pointer_diff (convert?@2 ADDR_EXPR@0) (convert?@3 @1)) + (pointer_diff (convert?@2 ADDR_EXPR@0) (convert1?@3 @1)) (if (tree_nop_conversion_p (TREE_TYPE(@2), TREE_TYPE (@0)) && tree_nop_conversion_p (TREE_TYPE(@3), TREE_TYPE (@1))) (with { poly_int64 diff; } (if (ptr_difference_const (@0, @1, &diff)) { build_int_cst_type (type, diff); })))) (simplify - (pointer_diff (convert?@2 @0) (convert?@3 ADDR_EXPR@1)) + (pointer_diff (convert?@2 @0) (convert1?@3 ADDR_EXPR@1)) (if (tree_nop_conversion_p (TREE_TYPE(@2), TREE_TYPE (@0)) && tree_nop_conversion_p (TREE_TYPE(@3), TREE_TYPE (@1))) (with { poly_int64 diff; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0dcc3b46858..7b9627f0b95 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-07-13 Richard Biener + + PR middle-end/85974 + * gcc.c-torture/compile/930326-1.c: Adjust to cover widening. + 2018-07-13 Tom de Vries * gcc.dg/guality/clztest.c: Add -fno-ipa-icf in dg-options. diff --git a/gcc/testsuite/gcc.c-torture/compile/930326-1.c b/gcc/testsuite/gcc.c-torture/compile/930326-1.c index 97313d86aa9..74f4ef63637 100644 --- a/gcc/testsuite/gcc.c-torture/compile/930326-1.c +++ b/gcc/testsuite/gcc.c-torture/compile/930326-1.c @@ -4,3 +4,4 @@ struct } s; long i = s.f-&s.b; +long long j = s.f-&s.b;