This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR41491
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 2 Dec 2009 19:11:08 +0100 (CET)
- Subject: [PATCH] Fix PR41491
This fixes an ICE in VRP that happens because we leak arithmetic
in domain types into the IL. That's generally a bad idea as they
have the same issue as Ada sub-types. Now of course they are not
part of any arithmetic originally so there's no reason to change
that at any point.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2009-12-02 Richard Guenther <rguenther@suse.de>
PR middle-end/41491
* fold-const.c (try_move_mult_to_index): Do not leak
domain types into the IL.
Index: gcc/fold-const.c
===================================================================
*** gcc/fold-const.c (revision 154913)
--- gcc/fold-const.c (working copy)
*************** try_move_mult_to_index (location_t loc,
*** 7586,7598 ****
{
if (TREE_CODE (ref) == ARRAY_REF)
{
/* Remember if this was a multi-dimensional array. */
if (TREE_CODE (TREE_OPERAND (ref, 0)) == ARRAY_REF)
mdim = true;
! itype = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (ref, 0)));
! if (! itype)
continue;
step = array_ref_element_size (ref);
if (TREE_CODE (step) != INTEGER_CST)
--- 7586,7601 ----
{
if (TREE_CODE (ref) == ARRAY_REF)
{
+ tree domain;
+
/* Remember if this was a multi-dimensional array. */
if (TREE_CODE (TREE_OPERAND (ref, 0)) == ARRAY_REF)
mdim = true;
! domain = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (ref, 0)));
! if (! domain)
continue;
+ itype = TREE_TYPE (domain);
step = array_ref_element_size (ref);
if (TREE_CODE (step) != INTEGER_CST)
*************** try_move_mult_to_index (location_t loc,
*** 7619,7636 ****
tree tmp;
if (TREE_CODE (TREE_OPERAND (ref, 1)) != INTEGER_CST
! || !INTEGRAL_TYPE_P (itype)
! || !TYPE_MAX_VALUE (itype)
! || TREE_CODE (TYPE_MAX_VALUE (itype)) != INTEGER_CST)
continue;
tmp = fold_binary_loc (loc, PLUS_EXPR, itype,
! fold_convert_loc (loc, itype,
! TREE_OPERAND (ref, 1)),
! fold_convert_loc (loc, itype, delta));
if (!tmp
|| TREE_CODE (tmp) != INTEGER_CST
! || tree_int_cst_lt (TYPE_MAX_VALUE (itype), tmp))
continue;
}
--- 7622,7638 ----
tree tmp;
if (TREE_CODE (TREE_OPERAND (ref, 1)) != INTEGER_CST
! || !TYPE_MAX_VALUE (domain)
! || TREE_CODE (TYPE_MAX_VALUE (domain)) != INTEGER_CST)
continue;
tmp = fold_binary_loc (loc, PLUS_EXPR, itype,
! fold_convert_loc (loc, itype,
! TREE_OPERAND (ref, 1)),
! fold_convert_loc (loc, itype, delta));
if (!tmp
|| TREE_CODE (tmp) != INTEGER_CST
! || tree_int_cst_lt (TYPE_MAX_VALUE (domain), tmp))
continue;
}