This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/66768] address space gets lost on literal pointer
- From: "amker at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 07 Jul 2015 08:43:54 +0000
- Subject: [Bug tree-optimization/66768] address space gets lost on literal pointer
- Auto-submitted: auto-generated
- References: <bug-66768-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66768
--- Comment #7 from amker at gcc dot gnu.org ---
(In reply to Richard Biener from comment #6)
> IVOPTs seems to carry address-space info on 'type' here (in fact if I amend
> tree dumping with address-space dumping on memory references I fail to get
> proper address-space info on the first function _before_ IVOPTs...).
>
> Address-space info is on the base object type, not on the type of the
> memory reference (for MEM_REF and TARGET_MEM_REF, that is).
>
> For the IVOPTs issue a way to fix the particular testcase is
>
> Index: gcc/tree-ssa-address.c
> ===================================================================
> --- gcc/tree-ssa-address.c (revision 225504)
> +++ gcc/tree-ssa-address.c (working copy)
> @@ -395,7 +395,7 @@ create_mem_ref_raw (tree type, tree alia
> }
> else
> {
> - base = build_int_cst (ptr_type_node, 0);
> + base = build_int_cst (build_pointer_type (type), 0);
> index2 = addr->base;
> }
>
> but then we ICE in convert_memory_address_addr_space_1
>
> #1 0x000000000093323b in convert_memory_address_addr_space_1 (
> to_mode=PSImode, x=0x7ffff69f5c60, as=7 '\a', in_const=false)
> at /space/rguenther/tramp3d/trunk/gcc/explow.c:282
> 282 gcc_assert (GET_MODE (x) == to_mode || GET_MODE (x) == VOIDmode);
> (gdb) p debug_rtx (x)
> (subreg:HI (reg:PSI 42 [ ivtmp.21 ]) 0)
>
> at least the address-space is now on the MEM_REF:
>
> <bb 3>:
> # total_11 = PHI <total_5(3), 0(2)>
> # ivtmp.21_2 = PHI <ivtmp.21_7(3), 4660(2)>
> _12 = (sizetype) ivtmp.21_2;
> _4 = MEM[base: 0B, index: _12, offset: 0B]<address-space-7> ;
>
> the ICE is probably a AVR bug (it's inside POITNERS_EXTEND_UNSIGNED).
> Possibly the subreg case can be applied for POINTERS_EXTEND_UNSIGNED as well.
Yes, I had tried this method and run into exactly the same ICE. I don't know
if it's AVR's bug so went into IVOPT for a fix. According to IVO comments,
rewrite_use_address&create_mem_ref should try their best to distribute
candidate var into base part pf MEM_REF/TARGET_MEM_REF if the cand actually
stands for address of memory reference. While it failed in this case.