From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58962 invoked by alias); 6 Jan 2017 16:06:57 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 58944 invoked by uid 89); 6 Jan 2017 16:06:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=no_reg, NO_REG, sk:find_re, H*f:sk:4377330 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Jan 2017 16:06:55 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB2C08050D; Fri, 6 Jan 2017 16:06:54 +0000 (UTC) Received: from localhost.localdomain (ovpn-118-153.rdu2.redhat.com [10.10.118.153]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v06G6rw6000831; Fri, 6 Jan 2017 11:06:54 -0500 Subject: Re: input address reload issue To: Aurelien Buhrig , gcc@gcc.gnu.org References: <094e7c3d-fc6c-1b0a-29c3-263cadec25a7@gmail.com> <43773302-1453-5c82-4da0-cf5332aeb8e2@redhat.com> From: Jeff Law Message-ID: Date: Fri, 06 Jan 2017 16:06:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00042.txt.bz2 On 01/06/2017 03:20 AM, Aurelien Buhrig wrote: > >>> So the insn: >>> (set (reg:QI 0 r0) (mem:QI (plus:SI (reg:SI 2 r2)(const_int 1)) >>> >>> is transformed into: >>> (set (reg:SI 8 a0) (reg:SI 2 r2)) >>> (set (reg:SI 8 a0) (const_int 1)) >>> (set (reg:SI 8 a0) (plus:SI (reg:SI 8 a0) (reg:SI 8 a0))) >>> (set (reg:QI 0 r0) (mem:QI (reg:SI 8 a0)) >>> >>> This "basic" transformation requires two reload regs, but only one is >>> given/used/possible from the rl structure (in emit_reload_insns). >>> >>> So where does the issue comes from? The need for 2 reload regs, the >>> transformation which is too "basic" and could be optimized to use only >>> one reload reg, or any wrong/missing reload target hook? >> Sounds like you need secondary or intermediate reloads. > Thank you Jeff for your help. > Currently, the TARGET_SECONDARY_RELOAD does not check if the address of > a mem rtx is legitimate address and it returns NO_REG with (mem:QI r2). So first you have to distinguish between an intermediate and scratch register. Intermediates say that to copy from a particular register class to a particular destination will require the source to first be copied into the intermediate register, then the intermediate to the final destination. So for example if you have a register that you can not directly store to memory, you might use an intermediate. The source register would be copied to the intermediate and the intermediate then stored to memory. Scratch registers are different -- essentially the backend tells reload that another register from a particular class is needed *and* the pattern to use for generating the reload. So as an example, you might have a two-register indexed address, For example, loading a constant into an FP register during PIC code generation may require a scratch register to hold intermediate address computations. You can have cases where you need both a scratch and an intermediate. You can also have cases where you need an intermediate memory location. > Do you suggest the secondary reload must implement a scratch reg & md > pattern to implement this reload? Perhaps. I don't know enough about your architecture to be 100% sure about how all the pieces interact with each other -- reload, and secondary reloads in particular are a complex area. I'm largely going on your comment that you need 2 reload registers. Presumably you don't have an instruction for (set (reg) (plus (reg) (const_int))) Thus you need two scratch reload regs IIUC. One to hold r2 another to hold (const_int 1). So you'd want to generate (set (areg1) (reg r2)) (set (areg2) (const_int 1)) (set (areg1) (plus (areg1) (areg2) (set (r0) (mem (areg1)) Or something along those lines. If you're going to stick with reload, you'll likely want to dig into find_reloads_address and its children to see what reloads it generates and why (debug_reload can be helpful here). jeff