[PATCH] Fix PR tree-opt/32527: ICE in build2_stat (aff_combination_scale)
Ian Lance Taylor
iant@google.com
Sat Jun 30 07:21:00 GMT 2007
Andrew_Pinski@PlayStation.Sony.Com writes:
> * tree-affine.c (aff_combination_scale): Use sizetype for
> mutiplication when the affine is a pointer type.
>
>
> * gfortran.fortran-torture/compile/pr32527.f90: New test.
>
>
> Index: testsuite/gfortran.fortran-torture/compile/pr32527.f90
> ===================================================================
> --- testsuite/gfortran.fortran-torture/compile/pr32527.f90 (revision 0)
> +++ testsuite/gfortran.fortran-torture/compile/pr32527.f90 (revision 0)
> @@ -0,0 +1,18 @@
> +! This code used to crash in aff_combination_scale while trying to generate a
> +! multiply in a pointer type
> +
> +function nf90_put_var_7D_FourByteInt(ncid, varid, values, start, count, stride, map)
> + integer, intent(in) :: ncid, varid
> + integer, dimension(:, :, :, :, :, :, :), intent(in) :: values
> + integer, dimension(:), intent(in) :: start, count, stride, map
> + integer :: nf90_put_var_7D_FourByteInt
> +
> + integer, dimension(1024) :: localStart, localCount, localStride, localMap
> +
> + integer, external :: nf_put_varm_int
> +
> + nf90_put_var_7D_FourByteInt = &
> + nf_put_varm_int (ncid, varid, localStart, localCount, localStride, localMap, &
> + int (values))
> +end function nf90_put_var_7D_FourByteInt
> +
> Index: tree-affine.c
> ===================================================================
> --- tree-affine.c (revision 126131)
> +++ tree-affine.c (working copy)
> @@ -119,8 +119,15 @@ aff_combination_scale (aff_tree *comb, d
> comb->n++;
> }
> else
> - comb->rest = fold_build2 (MULT_EXPR, comb->type, comb->rest,
> - double_int_to_tree (comb->type, scale));
> + {
> + tree type = comb->type;
> + /* The type of rest is sizetype for pointer types. */
> + if (POINTER_TYPE_P (type))
> + type = sizetype;
> +
> + comb->rest = fold_build2 (MULT_EXPR, type, comb->rest,
> + double_int_to_tree (type, scale));
> + }
> }
> }
>
This looks incomplete to me. The comment in tree-affine.h says that
the type of comb->rest must be comb->type, but this change breaks that
invariant. Is the comment wrong?
Also, the patch appears to assume that if comb->type is a pointer,
then the type of comb->rest will be sizetype. But I don't see
anything which enforces that.
Ian
More information about the Gcc-patches
mailing list