From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 118898 invoked by alias); 7 Jul 2015 11:17:38 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 118848 invoked by uid 48); 7 Jul 2015 11:17:34 -0000 From: "amker at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/66768] address space gets lost on literal pointer Date: Tue, 07 Jul 2015 11:17:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: amker at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-07/txt/msg00529.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66768 --- Comment #8 from amker at gcc dot gnu.org --- So address space info is kept and checked in base object's type of MEM_REF. As in function expand_expr_real_1: case TARGET_MEM_REF: { addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0)))); enum insn_code icode; unsigned int align; The AVR ICE happens when base of MEM_REF[base:0, index:(sizetype)ivtmp] has __memx address space attribute. Since pointer to memory object in __memx address space (PSImode) has 24 bits type length, while the type of index is sizetype(Pmode == HImode in this case), which has 16 bits type length. The expression "(sizetype)ivtmp" is expanded into (subreg:HI (reg:PSI 40) 0). So I still think IVO should distribute ivtmp as base part of MEM_REF since it stands for a memory object. Otherwise, we have below IVOed code: : # total_10 = PHI # ivtmp.7_8 = PHI _12 = (sizetype) ivtmp.7_8; _4 = MEM[base: 0B, index: _12, offset: 0B]; total_5 = _4 + total_10; ivtmp.7_7 = ivtmp.7_8 + 2; if (ivtmp.7_7 != 4700) goto ; else goto ; : goto ; This is wrong since truncation of ivtmp.7_8 to sizetype could result in wrong address. Thanks.