From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id E1A6E3858C33 for ; Wed, 19 Jul 2023 10:25:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E1A6E3858C33 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-out1.suse.de (Postfix) with ESMTP id D95E521AB2; Wed, 19 Jul 2023 10:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689762328; 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=hT1LCOugOvcZlZaKKG+DLKwkTU20VIg1OZocTos8nuY=; b=S2uUV620li4XFit9ocjfT4NBsSDrJR6KHa2CrxEWtk6DTN/+9o4i0vvKlqa09az5KhCgfG kUf3+aIT/kREzChElDzNfya9bjtOBJrFUQsYs+QDpJ1qwwJp9HOWfKpTDtNjKPCnkjnOYg +mE3qTtjg/FumG8q/70/o+c+B6pmDbM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689762328; 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=hT1LCOugOvcZlZaKKG+DLKwkTU20VIg1OZocTos8nuY=; b=8e9lfLwOP1ZEQKrRbGbcrfUJ3UYavj7s9PymP1Ciic5nBOLK7sExcbkfQ7N3wsbCDOVW1b JNXSlbPpNAil+xCQ== 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 6DEC82C142; Wed, 19 Jul 2023 10:25:28 +0000 (UTC) Date: Wed, 19 Jul 2023 10:25:28 +0000 (UTC) From: Richard Biener To: YunQiang Su cc: Eric Botcazou , gcc-patches@gcc.gnu.org, YunQiang Su , pinskia@gmail.com, jeffreyalaw@gmail.com, ian@airs.com Subject: Re: [PATCH v2] Store_bit_field_1: Use SUBREG instead of REG if possible In-Reply-To: Message-ID: References: <20230719041639.2967597-1-yunqiang.su@cipunited.com> <2289802.ElGaqSPkdT@arcturus> 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=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Wed, 19 Jul 2023, YunQiang Su wrote: > Eric Botcazou ?2023?7?19??? 17:45??? > > > > > I don't see that. That's definitely not what GCC expects here, > > > the left-most word of the doubleword should be unchanged. > > > > > > Your testcase should be a dg-do-run and probably more like > > > > > > NOMIPS16 int __attribute__((noipa)) test (const unsigned char *buf) > > > { > > > int val; > > > ((unsigned char*)&val)[0] = *buf++; > > > ((unsigned char*)&val)[1] = *buf++; > > > ((unsigned char*)&val)[2] = *buf++; > > > ((unsigned char*)&val)[3] = *buf++; > > > return val; > > > } > > > int main() > > > { > > > int val = 0x01020304; > > > val = test (&val); > > > if (val != 0x01020304) > > > abort (); > > > } > > > > > > not sure if I got endianess correct. Now, the question is what > > > WORD_REGISTER_OPERATIONS implies for a bitfield insert and what > > > the MIPS ABI says for returning SImode. > > > > MIPS N64 ABI uses 2 GPR for integer return values. > If the return value is SImode, the first v0 register is used, and it > must be sign-extended, > aka the bits[64-31] are all same. > > Yes, it is same for signed and unsigned int32. > > https://irix7.com/techpubs/007-2816-004.pdf > Page 6: > 32-bit integer (int) parameters are always sign-extended when passed > in registers, > whether of signed or unsigned type. [This issue does not arise in the > o32-bit ABI.] Note I think Andrews comment#7 in the PR is spot-on then, the issue isn't the bitfield inserts but the compare where combine elides the sign_extend in favor of a subreg. That's likely some wrongdoing in simplify-rtx in the context of WORD_REGISTER_OPERATIONS. Richard.