This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] for PR 27331
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 20 Jun 2006 12:18:03 +0200
- Subject: [patch] for PR 27331
Hello,
the code in create_data_ref does not handle the case when the access
function of the data reference cannot be analysed correctly, causing
an ICE. This patch fixes the problem by failing for such data
references. The patch was bootstrapped & regtested on i686 and ppc,
and pre-approved by Sebastian.
PR tree-optimization/27331
* tree-data-ref.c (free_data_ref): New function.
(create_data_ref): Fail if the data reference has unknown access
function.
(free_data_refs): Use free_data_ref.
* gcc.dg/pr27331.c: New test.
Index: testsuite/gcc.dg/pr27331.c
===================================================================
*** testsuite/gcc.dg/pr27331.c (revision 0)
--- testsuite/gcc.dg/pr27331.c (revision 0)
***************
*** 0 ****
--- 1,56 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -ftree-vectorize" } */
+
+ struct funny_match
+ {
+ int this, other;
+ };
+
+ typedef struct rtx {
+ int code;
+ } *rtx;
+
+ extern rtx recog_operand[];
+ extern int which_alternative;
+ extern int nalternatives;
+
+ int
+ constrain_operands (insn_code_num, strict)
+ int insn_code_num;
+ int strict;
+ {
+ char *constraints[10];
+ struct funny_match funny_match[10];
+ register int c;
+ int funny_match_index;
+
+ which_alternative = 0;
+
+ while (which_alternative < nalternatives)
+ {
+ register int opno;
+ register char *p = constraints[opno];
+ int lose = 0;
+ funny_match_index = 0;
+
+ while (*p && (c = *p++) != ',')
+ funny_match[funny_match_index++].other = c - '0';
+
+ if ((((recog_operand[opno])->code) == 12))
+ lose = 1;
+
+ if (!lose)
+ {
+ while (--funny_match_index >= 0)
+ recog_operand[funny_match[funny_match_index].other]
+ = recog_operand[funny_match[funny_match_index].this];
+ return 1;
+ }
+ which_alternative++;
+ }
+
+ if (strict == 0)
+ return constrain_operands (insn_code_num, -1);
+ return 0;
+ }
+
Index: tree-data-ref.c
===================================================================
*** tree-data-ref.c (revision 114781)
--- tree-data-ref.c (working copy)
*************** analyze_offset (tree offset, tree *invar
*** 1854,1859 ****
--- 1854,1871 ----
*invariant = invariant_0 ? invariant_0 : invariant_1;
}
+ /* Free the memory used by the data reference DR. */
+
+ static void
+ free_data_ref (data_reference_p dr)
+ {
+ if (DR_TYPE(dr) == ARRAY_REF_TYPE)
+ VEC_free (tree, heap, dr->object_info.access_fns);
+ else
+ VEC_free (tree, heap, dr->first_location.access_fns);
+
+ free (dr);
+ }
/* Function create_data_ref.
*************** create_data_ref (tree memref, tree stmt,
*** 1954,1964 ****
--- 1966,1988 ----
/* Update access function. */
access_fn = DR_ACCESS_FN (dr, 0);
+ if (automatically_generated_chrec_p (access_fn))
+ {
+ free_data_ref (dr);
+ return NULL;
+ }
+
new_step = size_binop (TRUNC_DIV_EXPR,
fold_convert (ssizetype, step), type_size);
init_cond = chrec_convert (chrec_type (access_fn), init_cond, stmt);
new_step = chrec_convert (chrec_type (access_fn), new_step, stmt);
+ if (automatically_generated_chrec_p (init_cond)
+ || automatically_generated_chrec_p (new_step))
+ {
+ free_data_ref (dr);
+ return NULL;
+ }
access_fn = chrec_replace_initial_condition (access_fn, init_cond);
access_fn = reset_evolution_in_loop (loop->num, access_fn, new_step);
*************** free_data_refs (VEC (data_reference_p, h
*** 4373,4386 ****
struct data_reference *dr;
for (i = 0; VEC_iterate (data_reference_p, datarefs, i, dr); i++)
! {
! if (DR_TYPE(dr) == ARRAY_REF_TYPE)
! VEC_free (tree, heap, (dr)->object_info.access_fns);
! else
! VEC_free (tree, heap, (dr)->first_location.access_fns);
!
! free (dr);
! }
VEC_free (data_reference_p, heap, datarefs);
}
--- 4397,4403 ----
struct data_reference *dr;
for (i = 0; VEC_iterate (data_reference_p, datarefs, i, dr); i++)
! free_data_ref (dr);
VEC_free (data_reference_p, heap, datarefs);
}