Ada bootstrap broken on x86 and x86_64
Jan Hubicka
hubicka@ucw.cz
Mon Sep 6 22:14:00 GMT 2004
> this should fix the problem. I think that the actual value of ADDR_EXPR
> (VIEW_CONVERT_EXPR (something)) is equivalent to ADDR_EXPR (something)
> so I can just ignore it when computing the offsets.
>
> Yes, but a lot of code code in peel_address looks quite wrong to me. You
> should never use TREE_INT_CST_LOW without checking that there's no high part
> set: that's what the function tree_low_cst is all about. I added that
> function back in March of 2000: nobody should be using TREE_CST_CST_LOW in
> this way.
>
> Moreover, the offset for a COMPONENT_REF must include DECL_FIELD_OFFSET and
> for an ARRAY_REF, you have to take into account the lower bound. he new
> functions in stor-layout.c (array_ref_low_bound, etc) should be used for this.
>
> But why not simply use get_inner_reference so that everybody finds offsets
> the same way? The bug with VIEW_CONVERT_EXPR couldn't have occurred if that
> were used.
Well, the code is not mine, I just promised to fix bugs while Zdenek is
away. However I am just testing the attached patch. Does it appear
sane?
thanks,
Honza
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.3
diff -c -3 -p -r2.3 tree-ssa-loop-ivopts.c
*** tree-ssa-loop-ivopts.c 6 Sep 2004 18:38:27 -0000 2.3
--- tree-ssa-loop-ivopts.c 6 Sep 2004 22:13:06 -0000
*************** force_var_cost (struct ivopts_data *data
*** 2513,2566 ****
static tree
peel_address (tree addr, unsigned HOST_WIDE_INT *diff)
{
! tree off, size;
! HOST_WIDE_INT bit_offset;
!
! switch (TREE_CODE (addr))
! {
! case SSA_NAME:
! case INDIRECT_REF:
! case BIT_FIELD_REF:
! case VAR_DECL:
! case PARM_DECL:
! case RESULT_DECL:
! case STRING_CST:
! case REALPART_EXPR:
! case IMAGPART_EXPR:
! return NULL_TREE;
!
! case COMPONENT_REF:
! off = DECL_FIELD_BIT_OFFSET (TREE_OPERAND (addr, 1));
! bit_offset = TREE_INT_CST_LOW (off);
!
! if (bit_offset % BITS_PER_UNIT)
! abort ();
!
! if (diff)
! *diff += bit_offset / BITS_PER_UNIT;
!
! return TREE_OPERAND (addr, 0);
!
! case ARRAY_REF:
! off = TREE_OPERAND (addr, 1);
!
! if (diff)
! {
! if (!cst_and_fits_in_hwi (off))
! return NULL_TREE;
!
! size = TYPE_SIZE_UNIT (TREE_TYPE (addr));
! if (!cst_and_fits_in_hwi (size))
! return NULL_TREE;
!
! *diff += TREE_INT_CST_LOW (off) * TREE_INT_CST_LOW (size);
! }
!
! return TREE_OPERAND (addr, 0);
!
! default:
! abort ();
! }
}
/* Checks whether E1 and E2 have constant difference, and if they do,
--- 2513,2532 ----
static tree
peel_address (tree addr, unsigned HOST_WIDE_INT *diff)
{
! HOST_WIDE_INT bitsize;
! HOST_WIDE_INT bitpos;
! tree offset;
! enum machine_mode mode;
! int unsignedp;
! int volatilep;
! tree obj;
!
! obj = get_inner_reference (addr, &bitsize, &bitpos, &offset, &mode, &unsignedp, &volatilep);
! if (bitpos % BITS_PER_UNIT || offset)
! return NULL_TREE;
! if (*diff)
! *diff += bitpos / BITS_PER_UNIT;
! return obj;
}
/* Checks whether E1 and E2 have constant difference, and if they do,
More information about the Gcc
mailing list