From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by sourceware.org (Postfix) with ESMTPS id DB3A03858D28; Thu, 28 Dec 2023 18:12:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB3A03858D28 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 DB3A03858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703787126; cv=none; b=TVK9ht8YXJA9UBYRw2Cm8VQGACXCrn9cRU7GMjECP4NMgi880HI+EWAliwiZUXr1rcYNhs1TNtvEE1M84OI6Vd9SNZ7DPbre4zpWTajtAUqOoP3SPh/zDBkLqhK5lEpWeNtdR4fqge9Lkx9EauMqtdm2CAPjLtdXOJbITQHoRnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703787126; c=relaxed/simple; bh=iDyuAmtjgTuk9BO5QDBr4JZPNTsSrokA+i2ezSXi3kM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=XK93qYXVEmLUHYVdGFtAwAQsc73xDGaVUPWMno8vb3QZkTxMXkK5MDLOuNJ+2ub+crLxIxTPDTkSZMqJ4iqZw1AMeVDB1B4SNRdWF9ZrMlbpLnWyUrNbhK4tgWQeRZMS7gDT3NrmGudNejpfe2UgZu7EM2gSW09kAXg5E0Q0bfk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-5945ba54d54so2306122eaf.3; Thu, 28 Dec 2023 10:12:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703787122; x=1704391922; darn=gcc.gnu.org; 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=tYGbByIIu/33lLcMXGaC4DPamvnQpxCX8s6PtxbuA0o=; b=NfKQArExcT2mH+uL5C+CA859+rt3lJYzUGcIEVpXXD+XzmfFm7fZQR/pSZIx6uMQa7 Kh7nVkNK/IR5zIcVx0ZVCfFrMOAkA6lm5B9Hk6IcFl2JZTRBpM788S+PP5revDUoGtSz RIQGBWXNlQvvYnv1AjPN0VteqaqMTT5pUc3fQJq2/UyVkb4IC0vpNDm9VDlaB0EoUmSN V6Gf18edXUGzQEg6bMsu1zxOyEMTY/28UVJ1UieBgMKIQj6mXU9qEh8G1Cdon3DwlhKv zIeEyB3ihano3MRj4S8y7xXehkXLYiAWWvfQUEOilMmsDGaqQnLPSeKikVXwh0pclP/a cZew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703787122; x=1704391922; 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=tYGbByIIu/33lLcMXGaC4DPamvnQpxCX8s6PtxbuA0o=; b=rdQju35yT9GWs/DWxKZNoK80P5+CQCHuzh8AEqFhHYdTSKVpFAEFiawqUZjYQRC2uR G237Fpiysn5s3MlhgSrYegDwHAGfkV27iqjGa0FSyida7uPDJoH6GuKuAVfPGCKQtEnY vgoMdM9S2fupBTAKhfWAXAV295zL7+oBulPBgng8K2vFlgfr/t1y3yZda2cphyyp7kXH EkmDIFKdkoMynrXp2eKBIwnSZAGCq0MYdIzvLwbwS7XkFZmP12RwzDrJdZumNnVQxJ48 xFUzCepwXwsePIrJH8Z8qOEyeEwe2tJ+gruZj3U66nLLI2fcxkX447fvYUtAarI6DsBY 2yww== X-Gm-Message-State: AOJu0YyUSVaS4J9maAR0BBO+r/WvaVoiN+AVkQ19PCBa94a7HHX6YkWT 9hOIDC8Hl62sX9MVV3RYdD3bfNECFGY= X-Google-Smtp-Source: AGHT+IETMTnj5fbfgEDYrVa4IZmIynFva1oCvsQiuUqNt3C2ewmtHtWN8EP/R4hRjvEIWeWPMQzlmw== X-Received: by 2002:a05:6358:106:b0:174:f1c7:f9f1 with SMTP id f6-20020a056358010600b00174f1c7f9f1mr5775715rwa.37.1703787121639; Thu, 28 Dec 2023 10:12:01 -0800 (PST) Received: from ?IPV6:2607:fb91:1dfa:8702:b88c:e239:7328:301b? ([2607:fb91:1dfa:8702:b88c:e239:7328:301b]) by smtp.gmail.com with ESMTPSA id gx9-20020a056a001e0900b006d9a0694f93sm9921526pfb.205.2023.12.28.10.11.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Dec 2023 10:12:00 -0800 (PST) Message-ID: <61a5c2cf-ef9f-4c52-864b-d58683c15828@gmail.com> Date: Thu, 28 Dec 2023 11:11:57 -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 Cc: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com, pinskia@gmail.com, rguenther@suse.de References: <20231223085858.4136369-1-syq@gcc.gnu.org> <04a01582-2bff-496f-95b1-4643b5a2f494@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,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 12/24/23 01:11, YunQiang Su wrote: >>> Yes. I also guess so. Any new idea? >> Well, I see multiple intertwined issues and I think MIPS has largely >> mucked this up. >> >> At a high level DI -> SI truncation is not a nop on MIPS64. We must >> explicitly sign extend the value from SI->DI to preserve the invariant >> that SI mode objects are extended to DImode. If we fail to do that, >> then the SImode conditional branch patterns simply aren't going to work. >> > > MIPS64 never claims DI -> SI is nop, instead it claims SI -> DI is nop. And that just seems wrong, at least for truncation which implies the input precision must be larger than the output precision. If you adjust the mips implementation of TARGET_TRULY_NOOP_TRUNCATION to return false when the input precision is smaller than the output precision, does that fix this problem? > And for MIPS64, it has only one type of branch. it works for both SI and DI. Agreed, but the SImode variant is really just a DImode comparison that relies on the sign extending property of the MIPS architecture. I'm not 100% sure that's safe in the presence of bit manipulation instructions which do not preserve the sign extending property. We actually don't allow some bit manipulations on RV64 for a similar underlying reason. > > Converting from 32 to 64 does be nop, IF the 32 is properly sign extended. But that's not a *truncation*, that's an *extension*. Jeff