From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 3A10C3858C5F for ; Fri, 4 Aug 2023 16:23:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A10C3858C5F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bba2318546so19795415ad.1 for ; Fri, 04 Aug 2023 09:23:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691166194; x=1691770994; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=iXncCkh5mdYBrpcLzAB+4UEf8bTy3YexN9Afm5PGzNY=; b=RJND+QSBrFlWdGICBSxOzJ7HOEtWg9dQ3MFCKUl+MW7RlyC8ejAxj+VZEZVj+ZlgxG TpiOOuWJEiSf5lL9paJn4lsMnZXqkfxyq+IQhS0kpdawMCF6JICLxmt6iUsnp0JAgbjA bomdoyjyzljsPulLzwGkxLCxG92SpoLKNzreDWPF0QUQ8WdZywmYPVsnOAAZBQZFVenG I8YmSHlw3xF4dDUoVa+aWrqxBTjOwtCeKvJ7kea/GYa9JxIReuQe6M9qp6B6Hdb/XocW Xhu9wiqp5nLKWuJ25PA+PGLv/ozhv9hVX5X/pudTypGSB3mVBbOWkRfsXs4vOLC8wZ8+ kB5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691166194; x=1691770994; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iXncCkh5mdYBrpcLzAB+4UEf8bTy3YexN9Afm5PGzNY=; b=MetfaJ70gFtw5T3uf7puXlJEtC2cEfchEIVl9emSubMVoRI+j7JlZkSm/B816mXaOP qoxcwRcUwPrlSCPEDDmvD8CreitjfjsN4a2T6W02rts9vSjsfI+u4tX27uH5n2Fm70Tf aFpVs+rb1ChiYcjx8TTBYR2a71Th7eo93RVhVR1tfOaAGTB74VKWnM0SJWFZOW/kCdCV 9KUqQVGwVxKPahs3nCJ/iPCUXt6nGZgn6PQ4MXxVoXRs4EapjFzEDm3CjsGvQ0j0qmY0 eiuv4rCfgwm+mhyVdqsDWkhQMiZTmf3kRteibOI2qlMRB09T0lcY+GWyAkPD7xPqvlnk XoEQ== X-Gm-Message-State: AOJu0Yxzg+dB2EA68Hb/ChF4IlaKad4nRUw2jqMVb9gnA2UQ7ISYzt9x 1ciV4beDHwc+8y5ug4sWFTw= X-Google-Smtp-Source: AGHT+IE7dF4gw+HlQ+A82rlmb/fhwplHl+19ukknvr4uIl89ujngrQSirCxF+QIqcS8IC5eCtjzvSw== X-Received: by 2002:a17:903:2113:b0:1bb:a4e4:54b6 with SMTP id o19-20020a170903211300b001bba4e454b6mr2102892ple.62.1691166193892; Fri, 04 Aug 2023 09:23:13 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id ij17-20020a170902ab5100b001b9e86e05b7sm1997952plb.0.2023.08.04.09.23.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Aug 2023 09:23:13 -0700 (PDT) Message-ID: Date: Fri, 4 Aug 2023 10:23:12 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: RISC-V: Folding memory for FP + constant case Content-Language: en-US To: Manolis Tsamis Cc: Vineet Gupta , Philipp Tomsich , Jivan Hakobyan , gcc-patches@gcc.gnu.org References: <3c1f0f8a-34ed-abb2-8a49-3083a2cc55d2@gmail.com> <61c9b9c2-f52e-2b4e-6d02-62c991603c39@gmail.com> <64233838-fe5e-458d-1eaf-3025b5448d85@rivosinc.com> <91c12503-c288-5b81-8941-cc62bab2ee98@gmail.com> <73dc8b97-7a7b-d9a0-2e8e-b4a5aaa3ee93@rivosinc.com> <40176a5c-382d-809d-a4b1-06c6541c3670@gmail.com> From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 8/4/23 03:52, Manolis Tsamis wrote: > Hi all, > > It is true that regcprop currently does not propagate sp and hence > leela is not optimized, but from what I see this should be something > we can address. > > The reason that the propagation fails is this check that I have added > when I introduced maybe_copy_reg_attrs: > > else if (REG_POINTER (new_reg) != REG_POINTER (old_reg)) > { > /* Only a single instance of STACK_POINTER_RTX must exist and we cannot > modify it. Allow propagation if REG_POINTER for OLD_REG matches and > don't touch ORIGINAL_REGNO and REG_ATTRS. */ > return NULL_RTX; > } > > To be honest I did add this back then just to be on the safe side of > whether a mismatch in REG_POINTER after propagation would be an issue > (since the original regcprop had caused enough problems). No worries. Obviously not propagating is the safe thing to do and if we find notable missed cases we can always refine the existing code like we're considering now. > > I see two ways to solve this and make fmo able to optimize leela as well: > 1) Remove the REG_POINTER check in regcprop if that is safe. My > understanding is that REG_POINTER is used as a hint and there would be > no correctness issues. REG_POINTER is meant to be conservatively correct. If REG_POINTER is set, then the register must be a pointer to a valid memory location. If REG_POINTER is not set, then it may or may not point to a valid memory location. sp, fp, ap are by definition pointers and thus have REG_POINTER set. With that definition we can safely copy propagate away an sp->gpr copy from a REG_POINTER standpoint. > 2) Mark the corresponding registers with REG_POINTER. I'm not sure > where that is supposed to happen. > > Since the instructions look like this: > (insn 113 11 16 2 (set (reg:DI 15 a5 [226]) > (reg/f:DI 2 sp)) 179 {*movdi_64bit} > (nil)) > > I assume that we'd want to mark a5 as REG_POINTER anyway (which is > not), and in that case propagation would work. I'd strongly recommend against that. The problem is the destination register might have been used in another context as an index register. We've fixed a few bugs in this space through the years I suspect there may be others lurking. You can't directly set that up in C code, but once you get down to RTL it can happen. > On the other hand if there's no correctness issue w.r.t. REG_POINTER > and regcprop then removing the additional check would increase > propagation opportunities in general which is also good. I think you can safely remove this limitation. jeff