re PR tree-optimization/59779 (FAIL: gcc.dg/autopar/outer-1.c scan-tree-dump-times parloops "parallelizing outer loop")

PR tree-optimization/59779
	* tree-dfa.c (get_ref_base_and_extent): Use double_int
	type for bitsize and maxsize instead of HOST_WIDE_INT.

From-SVN: r208554
This commit is contained in:
Jakub Jelinek 2014-03-13 20:10:05 +01:00 committed by Jakub Jelinek
parent 52684bb3c8
commit 5b5d7f31c2
2 changed files with 75 additions and 58 deletions

View File

@ -1,3 +1,9 @@
2014-03-13 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/59779
* tree-dfa.c (get_ref_base_and_extent): Use double_int
type for bitsize and maxsize instead of HOST_WIDE_INT.
2014-03-13 Steven Bosscher <steven@gcc.gnu.org> 2014-03-13 Steven Bosscher <steven@gcc.gnu.org>
PR rtl-optimization/57320 PR rtl-optimization/57320

View File

@ -389,11 +389,10 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
HOST_WIDE_INT *psize, HOST_WIDE_INT *psize,
HOST_WIDE_INT *pmax_size) HOST_WIDE_INT *pmax_size)
{ {
HOST_WIDE_INT bitsize = -1; double_int bitsize = double_int_minus_one;
HOST_WIDE_INT maxsize = -1; double_int maxsize;
tree size_tree = NULL_TREE; tree size_tree = NULL_TREE;
double_int bit_offset = double_int_zero; double_int bit_offset = double_int_zero;
HOST_WIDE_INT hbit_offset;
bool seen_variable_array_ref = false; bool seen_variable_array_ref = false;
/* First get the final access size from just the outermost expression. */ /* First get the final access size from just the outermost expression. */
@ -407,15 +406,11 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
if (mode == BLKmode) if (mode == BLKmode)
size_tree = TYPE_SIZE (TREE_TYPE (exp)); size_tree = TYPE_SIZE (TREE_TYPE (exp));
else else
bitsize = GET_MODE_BITSIZE (mode); bitsize = double_int::from_uhwi (GET_MODE_BITSIZE (mode));
}
if (size_tree != NULL_TREE)
{
if (! tree_fits_uhwi_p (size_tree))
bitsize = -1;
else
bitsize = tree_to_uhwi (size_tree);
} }
if (size_tree != NULL_TREE
&& TREE_CODE (size_tree) == INTEGER_CST)
bitsize = tree_to_double_int (size_tree);
/* Initially, maxsize is the same as the accessed element size. /* Initially, maxsize is the same as the accessed element size.
In the following it will only grow (or become -1). */ In the following it will only grow (or become -1). */
@ -448,7 +443,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
referenced the last field of a struct or a union member referenced the last field of a struct or a union member
then we have to adjust maxsize by the padding at the end then we have to adjust maxsize by the padding at the end
of our field. */ of our field. */
if (seen_variable_array_ref && maxsize != -1) if (seen_variable_array_ref && !maxsize.is_minus_one ())
{ {
tree stype = TREE_TYPE (TREE_OPERAND (exp, 0)); tree stype = TREE_TYPE (TREE_OPERAND (exp, 0));
tree next = DECL_CHAIN (field); tree next = DECL_CHAIN (field);
@ -459,15 +454,22 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
{ {
tree fsize = DECL_SIZE_UNIT (field); tree fsize = DECL_SIZE_UNIT (field);
tree ssize = TYPE_SIZE_UNIT (stype); tree ssize = TYPE_SIZE_UNIT (stype);
if (tree_fits_shwi_p (fsize) if (fsize == NULL
&& tree_fits_shwi_p (ssize) || TREE_CODE (fsize) != INTEGER_CST
&& doffset.fits_shwi ()) || ssize == NULL
maxsize += ((tree_to_shwi (ssize) || TREE_CODE (ssize) != INTEGER_CST)
- tree_to_shwi (fsize)) maxsize = double_int_minus_one;
* BITS_PER_UNIT
- doffset.to_shwi ());
else else
maxsize = -1; {
double_int tem = tree_to_double_int (ssize)
- tree_to_double_int (fsize);
if (BITS_PER_UNIT == 8)
tem = tem.lshift (3);
else
tem *= double_int::from_uhwi (BITS_PER_UNIT);
tem -= doffset;
maxsize += tem;
}
} }
} }
} }
@ -477,13 +479,12 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
/* We need to adjust maxsize to the whole structure bitsize. /* We need to adjust maxsize to the whole structure bitsize.
But we can subtract any constant offset seen so far, But we can subtract any constant offset seen so far,
because that would get us out of the structure otherwise. */ because that would get us out of the structure otherwise. */
if (maxsize != -1 if (!maxsize.is_minus_one ()
&& csize && csize
&& tree_fits_uhwi_p (csize) && TREE_CODE (csize) == INTEGER_CST)
&& bit_offset.fits_shwi ()) maxsize = tree_to_double_int (csize) - bit_offset;
maxsize = tree_to_uhwi (csize) - bit_offset.to_shwi ();
else else
maxsize = -1; maxsize = double_int_minus_one;
} }
} }
break; break;
@ -520,13 +521,12 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
/* We need to adjust maxsize to the whole array bitsize. /* We need to adjust maxsize to the whole array bitsize.
But we can subtract any constant offset seen so far, But we can subtract any constant offset seen so far,
because that would get us outside of the array otherwise. */ because that would get us outside of the array otherwise. */
if (maxsize != -1 if (!maxsize.is_minus_one ()
&& asize && asize
&& tree_fits_uhwi_p (asize) && TREE_CODE (asize) == INTEGER_CST)
&& bit_offset.fits_shwi ()) maxsize = tree_to_double_int (asize) - bit_offset;
maxsize = tree_to_uhwi (asize) - bit_offset.to_shwi ();
else else
maxsize = -1; maxsize = double_int_minus_one;
/* Remember that we have seen an array ref with a variable /* Remember that we have seen an array ref with a variable
index. */ index. */
@ -539,7 +539,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
break; break;
case IMAGPART_EXPR: case IMAGPART_EXPR:
bit_offset += double_int::from_uhwi (bitsize); bit_offset += bitsize;
break; break;
case VIEW_CONVERT_EXPR: case VIEW_CONVERT_EXPR:
@ -553,7 +553,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
{ {
exp = TREE_OPERAND (TMR_BASE (exp), 0); exp = TREE_OPERAND (TMR_BASE (exp), 0);
bit_offset = double_int_zero; bit_offset = double_int_zero;
maxsize = -1; maxsize = double_int_minus_one;
goto done; goto done;
} }
/* Fallthru. */ /* Fallthru. */
@ -569,13 +569,12 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
base type boundary. This needs to include possible trailing base type boundary. This needs to include possible trailing
padding that is there for alignment purposes. */ padding that is there for alignment purposes. */
if (seen_variable_array_ref if (seen_variable_array_ref
&& maxsize != -1 && !maxsize.is_minus_one ()
&& (!bit_offset.fits_shwi () && (TYPE_SIZE (TREE_TYPE (exp)) == NULL_TREE
|| !tree_fits_uhwi_p (TYPE_SIZE (TREE_TYPE (exp))) || TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST
|| (bit_offset.to_shwi () + maxsize || (bit_offset + maxsize
== (HOST_WIDE_INT) tree_to_uhwi == tree_to_double_int (TYPE_SIZE (TREE_TYPE (exp))))))
(TYPE_SIZE (TREE_TYPE (exp)))))) maxsize = double_int_minus_one;
maxsize = -1;
/* Hand back the decl for MEM[&decl, off]. */ /* Hand back the decl for MEM[&decl, off]. */
if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR) if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR)
@ -606,25 +605,32 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
/* We need to deal with variable arrays ending structures. */ /* We need to deal with variable arrays ending structures. */
if (seen_variable_array_ref if (seen_variable_array_ref
&& maxsize != -1 && !maxsize.is_minus_one ()
&& (!bit_offset.fits_shwi () && (TYPE_SIZE (TREE_TYPE (exp)) == NULL_TREE
|| !tree_fits_uhwi_p (TYPE_SIZE (TREE_TYPE (exp))) || TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST
|| (bit_offset.to_shwi () + maxsize || (bit_offset + maxsize
== (HOST_WIDE_INT) tree_to_uhwi == tree_to_double_int (TYPE_SIZE (TREE_TYPE (exp))))))
(TYPE_SIZE (TREE_TYPE (exp)))))) maxsize = double_int_minus_one;
maxsize = -1;
done: done:
if (!bit_offset.fits_shwi ()) if (!bitsize.fits_shwi () || bitsize.is_negative ())
{ {
*poffset = 0; *poffset = 0;
*psize = bitsize; *psize = -1;
*pmax_size = -1; *pmax_size = -1;
return exp; return exp;
} }
hbit_offset = bit_offset.to_shwi (); *psize = bitsize.to_shwi ();
if (!bit_offset.fits_shwi ())
{
*poffset = 0;
*pmax_size = -1;
return exp;
}
/* In case of a decl or constant base object we can do better. */ /* In case of a decl or constant base object we can do better. */
@ -632,25 +638,30 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
{ {
/* If maxsize is unknown adjust it according to the size of the /* If maxsize is unknown adjust it according to the size of the
base decl. */ base decl. */
if (maxsize == -1 if (maxsize.is_minus_one ()
&& tree_fits_uhwi_p (DECL_SIZE (exp))) && DECL_SIZE (exp)
maxsize = tree_to_uhwi (DECL_SIZE (exp)) - hbit_offset; && TREE_CODE (DECL_SIZE (exp)) == INTEGER_CST)
maxsize = tree_to_double_int (DECL_SIZE (exp)) - bit_offset;
} }
else if (CONSTANT_CLASS_P (exp)) else if (CONSTANT_CLASS_P (exp))
{ {
/* If maxsize is unknown adjust it according to the size of the /* If maxsize is unknown adjust it according to the size of the
base type constant. */ base type constant. */
if (maxsize == -1 if (maxsize.is_minus_one ()
&& tree_fits_uhwi_p (TYPE_SIZE (TREE_TYPE (exp)))) && TYPE_SIZE (TREE_TYPE (exp))
maxsize = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (exp))) - hbit_offset; && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST)
maxsize = tree_to_double_int (TYPE_SIZE (TREE_TYPE (exp)))
- bit_offset;
} }
/* ??? Due to negative offsets in ARRAY_REF we can end up with /* ??? Due to negative offsets in ARRAY_REF we can end up with
negative bit_offset here. We might want to store a zero offset negative bit_offset here. We might want to store a zero offset
in this case. */ in this case. */
*poffset = hbit_offset; *poffset = bit_offset.to_shwi ();
*psize = bitsize; if (!maxsize.fits_shwi () || maxsize.is_negative ())
*pmax_size = maxsize; *pmax_size = -1;
else
*pmax_size = maxsize.to_shwi ();
return exp; return exp;
} }