From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 38A953858D35; Fri, 9 Jun 2023 10:57:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38A953858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 448C71FDF8; Fri, 9 Jun 2023 10:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686308240; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=alGMzzznw/c8PkwHdIXFK5I7hvGALWzP1Ujk0d27Zlk=; b=gAjLG+9iLADkIUaTFhtrjN6orvBebypFQ+rf18Km/06SvEOBjAWDgMqcQR+eSSzTUJnUNy R/KESy8VatbleJZ31P4XJpcXdiDspnr6+re+gMGxULr+ojSJt8+Noq9biyUuqJgSyrScgs TX2T60Q4GRVEp/CmIGXNoJALHREi4IA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686308240; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=alGMzzznw/c8PkwHdIXFK5I7hvGALWzP1Ujk0d27Zlk=; b=mwhwwSORj1g9zvT9ed3KpKP6Ca/yEGC2g9IILnuZbebI3LQNwNHnzmFa2y0V51UL9+HQFf wADEajaIf7m5JqCQ== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id D1A042C141; Fri, 9 Jun 2023 10:57:19 +0000 (UTC) Date: Fri, 9 Jun 2023 10:57:19 +0000 (UTC) From: Richard Biener To: Jiufu Guo cc: Richard Sandiford , gcc-patches@gcc.gnu.org, jeffreyalaw@gmail.com, segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, bergner@linux.ibm.com Subject: Re: [PATCH] Make sure SCALAR_INT_MODE_P before invoke try_const_anchors In-Reply-To: <7nwn0dgfvj.fsf@ltcden2-lp1.aus.stglabs.ibm.com> Message-ID: References: <20230609052847.2128612-1-guojiufu@linux.ibm.com> <56dbba43adda001d1668c29e8024c85d@linux.ibm.com> <7nwn0dgfvj.fsf@ltcden2-lp1.aus.stglabs.ibm.com> User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 Fri, 9 Jun 2023, Jiufu Guo wrote: > > Hi, > > Richard Biener writes: > > > On Fri, 9 Jun 2023, Richard Sandiford wrote: > > > >> guojiufu writes: > >> > Hi, > >> > > >> > On 2023-06-09 16:00, Richard Biener wrote: > >> >> On Fri, 9 Jun 2023, Jiufu Guo wrote: > >> >> > >> >>> Hi, > >> >>> > >> >>> As checking the code, there is a "gcc_assert (SCALAR_INT_MODE_P > >> >>> (mode))" > >> >>> in "try_const_anchors". > >> >>> This assert seems correct because the function try_const_anchors cares > >> >>> about integer values currently, and modes other than SCALAR_INT_MODE_P > >> >>> are not needed to support. > >> >>> > >> >>> This patch makes sure SCALAR_INT_MODE_P when calling > >> >>> try_const_anchors. > >> >>> > >> >>> This patch is raised when drafting below one. > >> >>> https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603530.html. > >> >>> With that patch, "{[%1:DI]=0;} stack_tie" with BLKmode runs into > >> >>> try_const_anchors, and hits the assert/ice. > >> >>> > >> >>> Boostrap and regtest pass on ppc64{,le} and x86_64. > >> >>> Is this ok for trunk? > >> >> > >> >> Iff the correct fix at all (how can a CONST_INT have BLKmode?) then > >> >> I suggest to instead fix try_const_anchors to change > >> >> > >> >> /* CONST_INT is used for CC modes, but we should leave those alone. > >> >> */ > >> >> if (GET_MODE_CLASS (mode) == MODE_CC) > >> >> return NULL_RTX; > >> >> > >> >> gcc_assert (SCALAR_INT_MODE_P (mode)); > >> >> > >> >> to > >> >> > >> >> /* CONST_INT is used for CC modes, leave any non-scalar-int mode > >> >> alone. */ > >> >> if (!SCALAR_INT_MODE_P (mode)) > >> >> return NULL_RTX; > >> >> > >> > > >> > This is also able to fix this issue. there is a "Punt on CC modes" > >> > patch > >> > to return NULL_RTX in try_const_anchors. > >> > > >> >> but as said I wonder how we arrive at a BLKmode CONST_INT and whether > >> >> we should have fended this off earlier. Can you share more complete > >> >> RTL of that stack_tie? > >> > > >> > > >> > (insn 15 14 16 3 (parallel [ > >> > (set (mem/c:BLK (reg/f:DI 1 1) [1 A8]) > >> > (const_int 0 [0])) > >> > ]) "/home/guojiufu/temp/gdb.c":13:3 922 {stack_tie} > >> > (nil)) > >> > > >> > It is "set (mem/c:BLK (reg/f:DI 1 1) (const_int 0 [0])". > >> > >> I'm not convinced this is correct RTL. (unspec:BLK [(const_int 0)] ...) > >> would be though. It's arguably more accurate too, since the effect > >> on the stack locations is unspecified rather than predictable. > > > > powerpc seems to be the only port with a stack_tie that's not > > using an UNSPEC RHS. > In rs6000.md, it is > > ; This is to explain that changes to the stack pointer should > ; not be moved over loads from or stores to stack memory. > (define_insn "stack_tie" > [(match_parallel 0 "tie_operand" > [(set (mem:BLK (reg 1)) (const_int 0))])] > "" > "" > [(set_attr "length" "0")]) > > This would be just an placeholder insn, and acts as the comments. > UNSPEC_ would works like other targets. While, I'm wondering > the concerns on "set (mem:BLK (reg 1)) (const_int 0)". > MODEs between SET_DEST and SET_SRC? I don't think the issue is the mode but the issue is that the patter as-is says some memory is zeroed while that's not actually true (not specifying a size means we can't really do anything with this MEM, but still). Using an UNSPEC avoids implying anything for the stored value. Of course I think a MEM SET_DEST without a specified size is bougs as well, but there's larger precedent for this... Richard. > Thanks for comments! > > BR, > Jeff (Jiufu Guo) > > > >> Thanks, > >> Richard > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)