On Mon, Jan 2, 2012 at 1:06 PM, Eric Botcazou <ebotca...@adacore.com> wrote: >> Note that you'll get ICEs whenever TYPE_CANONICAL of some >> aggregate type is NULL (thus, TYPE_STRUCTURAL_EQUALITY), so this >> seems inherently fragile (similar to using TYPE_CANONICAL == TYPE_CANONICAL >> here, we'd break the TYPE_STRUCTURAL_EQUALITY case again). > > Could you elaborate? The patch was successfully regtested.
If you have nested structure types that are TYPE_STRUCTURAL_EQUALITY then they have TYPE_CANONICAL == NULL_TREE and types_compatible_p will return false (it ICEd in previous releases I believe) and thus you won't stop attaching COMPONENT_REFs. So the fix isn't complete. >> I think that either the original fix needs to be re-thought or we need to >> pass the base FIELD_DECL to build_ref_for_model. > >> That is, why not stop extracting the component-refs in >> >> do { >> tree field = TREE_OPERAND (expr, 1); >> tree cr_offset = component_ref_field_offset (expr); >> gcc_assert (cr_offset && host_integerp (cr_offset, 1)); >> >> offset -= TREE_INT_CST_LOW (cr_offset) * BITS_PER_UNIT; >> offset -= TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field)); >> >> VEC_safe_push (tree, stack, cr_stack, expr); >> >> expr = TREE_OPERAND (expr, 0); >> type = TREE_TYPE (expr); >> } while (TREE_CODE (expr) == COMPONENT_REF); >> >> when expr == base? > > Because SRA uses the model of the LHS to build the access on the RHS, so this > kind of equalitty condition cannot work. Ugh. >> The whole point of course was to never need something like >> build_ref_for_model given that we have MEM_REFs. > > MEM_REF is nice, but SRA should stop rewriting component accesses that it > doesn't scalarize, this is waste of time and memory, and introduces bugs. I agree - I didn't know it does that. Do you have an example? Richard. > -- > Eric Botcazou