diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-02-13 09:35:53 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-02-13 09:35:53 +0100 |
commit | 204a7ecb02199cdef17e445821c1effbfaf21bae (patch) | |
tree | 5acc0ef8db33596f096d2b3140f6820babe3bc45 /gcc/gimple-fold.c | |
parent | 848bb6fc0e502345536b25e1a110eb7f01eccbc1 (diff) | |
download | gcc-204a7ecb02199cdef17e445821c1effbfaf21bae.zip gcc-204a7ecb02199cdef17e445821c1effbfaf21bae.tar.gz gcc-204a7ecb02199cdef17e445821c1effbfaf21bae.tar.bz2 |
re PR tree-optimization/84339 (Wrong-code with optimizing strlen)
PR tree-optimization/84339
* gimple-fold.c (get_range_strlen): Set *FLEXP to true when handling
ARRAY_REF where first operand is array_at_struct_end_p COMPONENT_REF.
Formatting fixes.
* gcc.c-torture/execute/pr84339.c: New test.
From-SVN: r257618
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r-- | gcc/gimple-fold.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 3861692..e556f05 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -1380,9 +1380,15 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited, int type, /* Set the minimum size to zero since the string in the array could have zero length. */ *minlen = ssize_int (0); + + if (TREE_CODE (TREE_OPERAND (arg, 0)) == COMPONENT_REF + && type == TREE_TYPE (TREE_OPERAND (arg, 0)) + && array_at_struct_end_p (TREE_OPERAND (arg, 0))) + *flexp = true; } else if (TREE_CODE (arg) == COMPONENT_REF - && TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 1))) == ARRAY_TYPE) + && (TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 1))) + == ARRAY_TYPE)) { /* Use the type of the member array to determine the upper bound on the length of the array. This may be overly @@ -1428,7 +1434,7 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited, int type, || integer_zerop (val)) return false; val = wide_int_to_tree (TREE_TYPE (val), - wi::sub(wi::to_wide (val), 1)); + wi::sub (wi::to_wide (val), 1)); /* Set the minimum size to zero since the string in the array could have zero length. */ *minlen = ssize_int (0); |