From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by sourceware.org (Postfix) with ESMTPS id 9AFFB3858407; Tue, 9 Jan 2024 18:49:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9AFFB3858407 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9AFFB3858407 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d31 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704826161; cv=none; b=FvhbR1Bq6om/e90rfgXWm4mZW2UOzl6VjeNaBdl7hAm6vgs56vg15xbh2aZd9qtys9tOL+YphBTeRKShMBpEaeWS+xifah1uXO3gm8i5Qg6clgr/8BuTqz5dWp/R0IP6ArOWsl5i556klzUrrfoPRyiTD8/4u6q0v0N7JtvKQig= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704826161; c=relaxed/simple; bh=XJaIugEkYa6/Y0/otmiyro1wSCmkb9isMmW88mRwsuU=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=hwZLUwsiQk4RHwqOoEQ8w+VNTUyFmhX3pxLOI+nm9LgsZGc4IIlyCNbjLe+5o0fbeYuHxilE5H8NqPYH1vfTbCjtR44MrTpptKzISfodlXDqjn05I2IgIF0+9jpssLLtMBqrTYdnF8z8cSKMbxtE8TH6mH53jH6uC65mOCmEIoE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-7bee8858a8aso22257039f.0; Tue, 09 Jan 2024 10:49:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704826158; x=1705430958; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=lVmTKPiJfBPHQlhHXI5LCHYP4ZEJ9Wf0PSL8THXhUlM=; b=ccMSp6h4reZk2No/aSeQxb1RtBoJX9o8jIe1YmGnDjkukm9SmeptyXOU1gh918tV9H 8i+5R6WebB9K4vVO1ij0tybPigaONdOdAOZwULY2mNq87W9Tf3vFLiFrwxIXxplSJhkN 7dkOrkHaV4K/PhvkRxF3dLfYbNGn6ChDEPBkoeDup3AhnYCEnwP8odTXq6OXVWxMs3Mj +kByQEcyVTUYs4h40KohkOa4ieDeEieAkrxTXRkkHyBavLsplVtFnA7D/SjUIM8eU98P I6EKN+yGiY/nSD95MrANXI4ROTi0qgXmBvrB53zZukgZMUREnSXdGajhtOjuSAjVYwIP rEJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704826158; x=1705430958; h=content-transfer-encoding:in-reply-to:from:references: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=lVmTKPiJfBPHQlhHXI5LCHYP4ZEJ9Wf0PSL8THXhUlM=; b=c3fuMoW+U1WUkwJ6ctCjFR7C8FqxCzoygw/GXL0U+wQvhsntmMQq11wUF0eF5sqP+F s2BmU4GewtdcHdzDtqmPQ2HcY979lYeoky0X4TsrhjvCNuUOAbZT8neydFWzSRzqPx9j XXbOb95ZLmtJboXeHHXYwybMNpht60F9fjPxPyesDZeeyCRxO94UZ1F7Y+5ffN5k96yR HSsuBER35lPwKqcfXRyKy8XcuEwVwNnkmaMILHMoXzKc9my37dBAb4GjRVM3Ted1q4ue 2+ArLiRXmmVa3SNe8cuF9NV0o6cWLIN2M6W5zVOO8BYEuyBTjngUQEOCXh+ef6EPpvKi zyog== X-Gm-Message-State: AOJu0YzobPOULEZxZ0bp+IG3mPYVTigxqKGLfL8cNUNG1aGnbr8h6bYQ iQir+LfnCrBjS6TBpXlVB5XA00Lt4RU= X-Google-Smtp-Source: AGHT+IEMk+iSeHFko3XnbFHSh0wZeYBu4dQfXZVYz/mJ02ElCybj4wG2cWZZYZstAogfnhJeNk7X3Q== X-Received: by 2002:a5e:df03:0:b0:7ba:78b5:c6b7 with SMTP id f3-20020a5edf03000000b007ba78b5c6b7mr6961347ioq.22.1704826158291; Tue, 09 Jan 2024 10:49:18 -0800 (PST) Received: from [172.31.0.109] ([136.36.72.243]) by smtp.gmail.com with ESMTPSA id bc10-20020a0566383cca00b0046e435897d1sm69120jab.51.2024.01.09.10.49.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jan 2024 10:49:17 -0800 (PST) Message-ID: Date: Tue, 9 Jan 2024 11:49:16 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] EXPR: Emit an truncate if 31+ bits polluted for SImode Content-Language: en-US To: YunQiang Su , gcc-patches@gcc.gnu.org, pinskia@gmail.com, rguenther@suse.de, richard.sandiford@arm.com References: <20231223085858.4136369-1-syq@gcc.gnu.org> From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,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 1/3/24 16:39, Richard Sandiford wrote: > YunQiang Su writes: >> On TRULY_NOOP_TRUNCATION_MODES_P (DImode, SImode)) == true platforms, >> if 31 or above bits is polluted by an bitops, we will need an >> truncate. Let's emit one, and mark let's use the same hardreg >> as in and out, the RTL may like: >> >> (insn 21 20 24 2 (set (subreg/s/u:SI (reg/v:DI 200 [ val ]) 0) >> (truncate:SI (reg/v:DI 200 [ val ]))) "../xx.c":7:29 -1 >> (nil)) >> >> We use /s/u flags to mark it as really needed, as in >> combine_simplify_rtx, this insn may be considered as truncated, >> so let's skip this combination. >> >> gcc/ChangeLog: >> PR: 104914. >> * combine.cc (try_combine): Skip combine with truncate if >> dest is subreg and has /u/s flags on platforms >> TRULY_NOOP_TRUNCATION_MODES_P (DImode, SImode)) == true. >> * expr.cc (expand_assignment): Emit a truncate insn, if >> 31+ bits is polluted for SImode. >> >> gcc/testsuite/ChangeLog: >> PR: 104914. >> * gcc.target/mips/pr104914.c: New testcase. > > Sorry for not looking at this earlier. I've got a bit lost in the > various threads, so apologies if this has been discussed already > but I think the fix is: > > diff --git a/gcc/expr.cc b/gcc/expr.cc > index 4f42c0ff487..9847eba19fe 100644 > --- a/gcc/expr.cc > +++ b/gcc/expr.cc > @@ -6275,9 +6275,8 @@ expand_assignment (tree to, tree from, bool nontemporal) > else > { > rtx to_rtx1 > - = lowpart_subreg (subreg_unpromoted_mode (to_rtx), > - SUBREG_REG (to_rtx), > - subreg_promoted_mode (to_rtx)); > + = convert_to_mode (subreg_unpromoted_mode (to_rtx), > + SUBREG_REG (to_rtx), false); > result = store_field (to_rtx1, bitsize, bitpos, > bitregion_start, bitregion_end, > mode1, from, get_alias_set (to), > > (completely untested apart from the test case). That should still > produce a subreg on most targets, but generates the required trunc > on MIPS. I think this is a subset of Roger's work that got committed a few days back. jeff