From 5c8cebe7d6acb478309d6e03fd4df7e05d1b0f1e Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 16 Feb 2018 12:01:23 +0000 Subject: [PATCH] re PR tree-optimization/84417 (internal compiler error: verify_gimple failed) 2018-02-16 Richard Biener PR tree-optimization/84417 * tree-ssa.c (non_rewritable_mem_ref_base): Properly constrain the MEM_REF offset when conversion to BIT_FIELD_REF is desired. (non_rewritable_lvalue_p): Likewise, use poly-ints. * gcc.dg/torture/pr84417.c: New testcase. From-SVN: r257731 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr84417.c | 9 +++++++++ gcc/tree-ssa.c | 11 ++++++----- 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr84417.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9e7b575b38a..c43637aac5e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-02-16 Richard Biener + + PR tree-optimization/84417 + * tree-ssa.c (non_rewritable_mem_ref_base): Properly constrain + the MEM_REF offset when conversion to BIT_FIELD_REF is desired. + (non_rewritable_lvalue_p): Likewise, use poly-ints. + 2018-02-16 Martin Liska PR sanitizer/84307 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2ead408c90a..2d98e2e8024 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-16 Richard Biener + + PR tree-optimization/84417 + * gcc.dg/torture/pr84417.c: New testcase. + 2018-02-16 Jakub Jelinek PR target/84272 diff --git a/gcc/testsuite/gcc.dg/torture/pr84417.c b/gcc/testsuite/gcc.dg/torture/pr84417.c new file mode 100644 index 00000000000..9c2b023254b --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr84417.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target int32plus } */ + +void fn1() +{ + __attribute__((__vector_size__(sizeof(double)))) double x; + double *a = (double *)&x; + *a + *(a + 8446744073709551615LL); +} diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 949b951e1aa..d197f99bdd2 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1434,6 +1434,7 @@ non_rewritable_mem_ref_base (tree ref) || TREE_CODE (TREE_TYPE (decl)) == COMPLEX_TYPE) && useless_type_conversion_p (TREE_TYPE (base), TREE_TYPE (TREE_TYPE (decl))) + && known_ge (mem_ref_offset (base), 0) && known_gt (wi::to_poly_offset (TYPE_SIZE_UNIT (TREE_TYPE (decl))), mem_ref_offset (base)) && multiple_of_p (sizetype, TREE_OPERAND (base, 1), @@ -1516,11 +1517,11 @@ non_rewritable_lvalue_p (tree lhs) && TYPE_MODE (TREE_TYPE (decl)) != BLKmode && operand_equal_p (TYPE_SIZE_UNIT (TREE_TYPE (lhs)), TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (decl))), 0) - && tree_fits_uhwi_p (TREE_OPERAND (lhs, 1)) - && tree_int_cst_lt (TREE_OPERAND (lhs, 1), - TYPE_SIZE_UNIT (TREE_TYPE (decl))) - && (tree_to_uhwi (TREE_OPERAND (lhs, 1)) - % tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (lhs)))) == 0) + && known_ge (mem_ref_offset (lhs), 0) + && known_gt (wi::to_poly_offset (TYPE_SIZE_UNIT (TREE_TYPE (decl))), + mem_ref_offset (lhs)) + && multiple_of_p (sizetype, TREE_OPERAND (lhs, 1), + TYPE_SIZE_UNIT (TREE_TYPE (lhs)))) return false; } -- 2.30.2