This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR34458, ICE in data-ref with using int_cst_value
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 9 Jan 2008 15:15:43 +0100 (CET)
- Subject: Re: [PATCH] Fix PR34458, ICE in data-ref with using int_cst_value
- References: <Pine.LNX.4.64.0801091314580.4293@zhemvz.fhfr.qr>
On Wed, 9 Jan 2008, Richard Guenther wrote:
>
> Fixed by using tree_low_cst instead. For 4.4 we want to implement
> int_cst_value in terms of tree_low_cst instead (or get rid of
> int_cst_value by replacing all callers) - not appropriate at this stage
> though.
>
> The problem is that int_cst_value insists on the constants type being
> completely representable in a HOST_WIDE_INT. But what (usually) matters
> is, whether the actual constant fits in a HOST_WIDE_INT - which is
> what tree_low_cst ensures. 64bit types are common, but constants that
> do not fit in a 32bit type not, so this avoids the ICE.
>
> Note this doesn't fix the fundamental problem with data-ref, and as
> Zdenek mentions data-ref should possibly use double_ints for its
> calculations.
>
> But this is an easy and obvious fix here. Bootstrap and regtest in
> progress, I'll apply this after it completes.
Of course it isn't always _that_ easy. So, here's what I committed.
Richard.
2008-01-09 Richard Guenther <rguenther@suse.de>
PR middle-end/34458
* tree-data-ref.c (initialize_matrix_A): Use tree_low_cst,
adjust return type.
* gcc.c-torture/compile/pr34458.c: New testcase.
Index: testsuite/gcc.c-torture/compile/pr34458.c
===================================================================
*** testsuite/gcc.c-torture/compile/pr34458.c (revision 0)
--- testsuite/gcc.c-torture/compile/pr34458.c (revision 0)
***************
*** 0 ****
--- 1,16 ----
+ /* Testcase by Martin Michlmayr <tbm@cyrius.com> */
+
+ typedef struct
+ {
+ int data[1024];
+ }
+ Lint;
+ Lint lint_operate (Lint a, long long ammount)
+ {
+ int index;
+ Lint ret;
+ for (index = 0; index < 24; index++)
+ ret.data[index] =
+ a.data[index + ammount / 32 + 1] << a.data[index + ammount / 32];
+ return ret;
+ }
Index: tree-data-ref.c
===================================================================
*** tree-data-ref.c (revision 131424)
--- tree-data-ref.c (working copy)
*************** analyze_siv_subscript_cst_affine (tree c
*** 1820,1834 ****
/* Helper recursive function for initializing the matrix A. Returns
the initial value of CHREC. */
! static int
initialize_matrix_A (lambda_matrix A, tree chrec, unsigned index, int mult)
{
gcc_assert (chrec);
if (TREE_CODE (chrec) != POLYNOMIAL_CHREC)
! return int_cst_value (chrec);
!
! A[index][0] = mult * int_cst_value (CHREC_RIGHT (chrec));
return initialize_matrix_A (A, CHREC_LEFT (chrec), index + 1, mult);
}
--- 1820,1843 ----
/* Helper recursive function for initializing the matrix A. Returns
the initial value of CHREC. */
! static HOST_WIDE_INT
initialize_matrix_A (lambda_matrix A, tree chrec, unsigned index, int mult)
{
+ tree type;
+
gcc_assert (chrec);
+ type = TREE_TYPE (chrec);
if (TREE_CODE (chrec) != POLYNOMIAL_CHREC)
! return tree_low_cst (chrec, TYPE_UNSIGNED (type)
! && !(TREE_CODE (type) == INTEGER_TYPE
! && TYPE_IS_SIZETYPE (type)));
!
! type = TREE_TYPE (CHREC_RIGHT (chrec));
! A[index][0] = mult * tree_low_cst (CHREC_RIGHT (chrec),
! TYPE_UNSIGNED (type)
! && !(TREE_CODE (type) == INTEGER_TYPE
! && TYPE_IS_SIZETYPE (type)));
return initialize_matrix_A (A, CHREC_LEFT (chrec), index + 1, mult);
}