From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 8CB683858D3C; Sun, 24 Dec 2023 05:38:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8CB683858D3C 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 8CB683858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703396316; cv=none; b=fKBMI1MEexEfHvrIQeb112FHFLZjGL4ob4vAj67rRI+kwPFuMFLfYVBq4LC8AUMH3ea5bgBzIZcCnhGG/pyHitfCI1NXDDTqiquIy54676C7jANkoniClLqMoNoDiPpdBCeA3PH8fwhOOtrF/+Ov1YEXlrfTjOMfZCbuFhKBGbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703396316; c=relaxed/simple; bh=88bQxBZ+d5M19g3bthH5IZyzrL2Qtu1qpJle5IGnE4M=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=orA3F/hdbe9WVp1L0CPGED65BPcyUsxAglP6Yo3zFW2F++ig8ji6jv4kuaCa2y2TbLOhGkYZW4oSN3ZN0N922EIWI3lYBSdjHjdktecgtWFBEdiZmeHpoyWcsf+HS6p6wYpig6D+fRgZnhRLJSj6+IuV3UeMU9gfBQ0LUDadgS4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6d728c75240so2763347b3a.1; Sat, 23 Dec 2023 21:38:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703396313; x=1704001113; 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=+ac0eAUqdIIr27vJ2EHyddZUO+GAvYwemk/XgfvLxkg=; b=NnJ7/+wMBG3Tk6E4iawT2BBzaE9Hl4FgIxB3sYR/MkJdaXsP5K/eLgN1mEmdK4wreY ns1zaBfEaV59VSKD0yp2epery1iNi7YuGiS7Ck7Hg6yaQoJAfqFghYK1d415FT5zkWNy pdOUkiY+u58DXuBJqjLFuNPLUUIatBIkzAAdpcYUeXjuhjG7UGEQVN6IVsD9+6i2sw97 +nG4kdfV8jVtm5KtXswQdOymUaGvUcQqS01GwvPTEJq9ikxt3ZETdj3eGKra7ae1zDtR mi2mZyjkoIfzt6eIMhMT1y3npN/jisPuQdHVStRl3i9nI3r2LmRO1dVsicXaR3l924RK AVxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703396313; x=1704001113; 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=+ac0eAUqdIIr27vJ2EHyddZUO+GAvYwemk/XgfvLxkg=; b=O4jrVK5JncgRhJV/i7q+JeZ+suj9e1sblOdKiq16TbyG8E08bLVfuTTxN0C+ARy2Rq NeBaCjOiH3usVsTXutJwF9+s0OJww3BQ7lL3NwbPX/d7RKDQC/fHYKKetbCNcThdpr0S /je+mtbE8UrVQraKhthqDBm1mKH5snWPO8+vQeucwOe1F1GZO5gAi2HZptOh+w3ahlsO 21jLK2Y92Lr9knhe3Exwsujq3qeQFIhkk8nt9Gk7ob6Qo6fmI2Fz12tS3OlZZlbZYlMq oMSapSwvuJaP1YnglW9qH/HocakCjUzpTgB+KtgmMZMgBOYrd2FhopAToUke44MyHQtV 5L0g== X-Gm-Message-State: AOJu0YwtSHqb7TAXYvU1gflpX3dXxvLnebU8/pt0R7oVtcMvKW7POq5g 6q/OmaCwa+PrfplMwEhZYaQ= X-Google-Smtp-Source: AGHT+IFD1u8ZTfu8VKYDMu4l1M21x6sC4STS5tzdJaXYvlr7ayG64EoPvic4z3Xh2yGUiMrgBx6DHA== X-Received: by 2002:a05:6a00:278b:b0:6d6:7c05:97fc with SMTP id bd11-20020a056a00278b00b006d67c0597fcmr4069628pfb.7.1703396313212; Sat, 23 Dec 2023 21:38:33 -0800 (PST) Received: from [172.31.1.103] ([172.56.168.179]) by smtp.gmail.com with ESMTPSA id m3-20020a62f203000000b006d98dd174c5sm3481466pfh.104.2023.12.23.21.38.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 23 Dec 2023 21:38:32 -0800 (PST) Message-ID: <7518ec8d-ac4a-4d3e-a063-caa0ee520acf@gmail.com> Date: Sat, 23 Dec 2023 22:38:30 -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: Roger Sayle , gcc-patches@gcc.gnu.org, 'YunQiang Su' References: <000901da3603$10e97cb0$32bc7610$@nextmovesoftware.com> From: Jeff Law In-Reply-To: <000901da3603$10e97cb0$32bc7610$@nextmovesoftware.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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/23/23 17:49, Roger Sayle wrote: > > Hi YunQiang (and Jeff), > >> MIPS claims TRULY_NOOP_TRUNCATION_MODES_P (DImode, SImode)) == >> true based on that the hard register is always sign-extended, but >> here the hard register is polluted by zero_extract. > > I suspect that the bug here is that the MIPS backend shouldn't be > returning true for TRULY_NOOP_TRUNCATION_MODES_P (DImode, SImode). > It's true that the backend stores SImode values in DImode registers > by sign extending them, but this doesn't mean that any DImode pseudo > register can be truncated to an SImode pseudo just by SUBREG/register > naming. As you point out, if the high bits of a DImode value are > random, truncation isn't a no-op, and requires an explicit > sign-extension instruction. What's exceedingly weird is T_N_T_M_P (DImode, SImode) isn't actually a truncation! The output precision is first, the input precision is second. The docs explicitly state the output precision should be smaller than the input precision (which makes sense for truncation). That's where I'd start with trying to untangle this mess. > > I agree with Jeff there's an invariant that isn't correctly being > modelled by the MIPS machine description. A machine description > probably shouldn't define an addsi3 pattern if what it actually > supports is (sign_extend:DI (truncate:SI (plus:DI (reg:DI x) (reg:DI > y)))) Trying to model this as SImode addition plus a SUBREG_PROMOTED > flag is less than ideal. It's less than ideal, but we ended up taking a similar approach in the RV world. We actually have a subset of 32bit instructions in rv64, including a 32bit add. The semantics are that it's a (sign_extend:DI (plus:SI (op1) (op2))) Modeling it that way was actually critical in eliminating redundant sign extensions. But regardless, it looks like there's something weird going on in the MIPS port. jeff