From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 2B7513858D1E for ; Wed, 25 Oct 2023 16:30:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B7513858D1E 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 2B7513858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698251413; cv=none; b=eqzzzBu4GY9b2GHz+bVNf/7NsH/5sHXu+HvbAkC5jwesLH1co7+05WbF8PG1ZZLJb2LjSBWUNDqHl+bNQpibahuMliacgjC8aBS2bJK2VqeQgf3UVnCKa84xcj/iu+sKRrAeZodmHiFaUyVBWGMoNEh4/zibyJ5SVQ29rNXIAHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698251413; c=relaxed/simple; bh=nMdntyWjtUs1sgiAKGS0H7+RYB+2cBzZA2Rm2AIztf4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=xLIB/t/TAlm1cVn2utotv4OxZvYJVjsoWFuQWR5rM35qL8Ewar6Ke2+t37owm0S/2+85tnzwyiMb0iMfZoPs8WdUm3tScx2rG1l1jR0vUi19PWhrvCaxJHy9Pl3ZmxZpWTVxKCQ3hLQbsZNYnU0sov9bqkOaJCln2MOOBw/vqCY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5aa7fdd1420so3677702a12.3 for ; Wed, 25 Oct 2023 09:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698251411; x=1698856211; 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=ZKeVaKVOug8Zcg8lVeeTcRfGZ01Ck6opHmVm2yCTuhA=; b=A5IFlmg/ZhmkmWL71NlsMA1eNbuOAsBLf42Lq1CboaHJPQX75mCSZnFL6xrw9BKaB/ 39AeT1Kv8Ro3JUqEPPGzcl0ZZa33ypbFAj4qlSJ94ZcNJCf37MRdBHEinAVL8DkxvVqW NxSiw39fBxxIwFTfdlED6J+RODBC6h1TpHdNxTy/QYlGDiSzSF6OiCzYo2h+76zUYdF7 mAH8htOV1DEJGEnCb5E74x6WSXYaenoZ98zJhU6eflPYdEwwXBQPgM9pb4hl0hCczmJZ yr34JWZd2V0+BOK4jI4dLZsUn+2C8ObThIL4iGTxU5oJmeIze/ndmDLF5XOzrA8OEV+M MdPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698251411; x=1698856211; 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=ZKeVaKVOug8Zcg8lVeeTcRfGZ01Ck6opHmVm2yCTuhA=; b=U/zq8mgWsrBjh3W8fdta/ub/uP1ziz5ixh1dFGhYIcVfNF24LAE6tLYKcSXmuJ35zv zR8l1ZIBU3w4nv/8s30Z1hYS1gCWCuESkqNti3H1KlLTmYCHw2zXjx5vZTdmuYnYIHm1 sUbagAuPuCPjKYA58HDkg/nyzOglrkVRTI4Stlc2UfUYQ/AMl3iF04OTgrBPM1w9oGh7 Su5z5Qn/whhNo0c/vJt+nLwz/YX2cD8Jm38MHoMVXWm/X8KG/lFJaY7SwvpHUGw19IgC 2j8RAW0Z52YLuLm+ioaFpsoQtl53rFpX0hQp5DjyMruRUneG+v9HlDWErMc6C6am5ZRT VuwQ== X-Gm-Message-State: AOJu0YwScB2Cl0LKT+1CROgrm9pPG0daJHj4Lhf+Ri5cEbniGGrgPa60 XRMfdOCpuuGjEcH6NfKUYhw= X-Google-Smtp-Source: AGHT+IG7plSe2NE5iMu2ZxMhmvFR7arUV8Hy6Czwfa8g0ztxIEgLNQlgAGCKnwdSml17uIHq7GgwJw== X-Received: by 2002:a05:6a21:398e:b0:17b:f565:7e09 with SMTP id ad14-20020a056a21398e00b0017bf5657e09mr6343714pzc.60.1698251410804; Wed, 25 Oct 2023 09:30:10 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id x17-20020aa79ad1000000b0069268e3a659sm9583298pfp.132.2023.10.25.09.30.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Oct 2023 09:30:10 -0700 (PDT) Message-ID: Date: Wed, 25 Oct 2023 10:30:04 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC] RISC-V: elide sign extend when expanding cmp_and_jump Content-Language: en-US To: Vineet Gupta , Robin Dapp , gcc-patches@gcc.gnu.org Cc: gnu-toolchain@rivosinc.com References: <20231025050155.627837-1-vineetg@rivosinc.com> <7fe582bc-d259-4d2a-bedf-4e1a334d7fc3@gmail.com> <04f85309-4b40-4797-a424-ff207dd0724d@rivosinc.com> From: Jeff Law In-Reply-To: <04f85309-4b40-4797-a424-ff207dd0724d@rivosinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP 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 10/25/23 10:25, Vineet Gupta wrote: > Hey Robin, > > On 10/25/23 00:12, Robin Dapp wrote: >> Hi Vineet, >> >> I was thinking of two things while skimming the code: >> >>   - Couldn't we do this in the expanders directly?  Or is the >>     subreg-promoted info gone until we reach that? > > Following is the call stack involved: > >   expand_gimple_cond >     do_compare_and_jump >        emit_cmp_and_jump_insns >            gen_cbranchqi4 >                riscv_expand_conditional_branch >                    riscv_emit_int_compare >                       riscv_extend_comparands > > > Last function is what introduces the extraneous sign extends, w/o taking > subreg-promoted into consideration and what my patch attempts to address. > >>   - Should some common-code part be more suited to handle that? >>     We already elide redundant sign-zero extensions for other >>     reasons.  Maybe we could add subreg promoted handling there? > > Not in the context of this specific issue. Robin's point (IIUC) is that if we put this logic into a zero/sign extend expander, then it'll get used for *any* attempt to zero/sign extend that goes through the target expander. It doesn't work for your case because we use gen_rtx_{ZERO,SIGN}_EXTEND directly. But if those were adjusted to use the expander, then Robin's idea would be applicable to this case too. Jeff