From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id 202A63831E50 for ; Fri, 16 Dec 2022 17:19:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 202A63831E50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102c.google.com with SMTP id fa4-20020a17090af0c400b002198d1328a0so9128832pjb.0 for ; Fri, 16 Dec 2022 09:19:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=GfNYD/Eo98L+pHqqPXbFpUQXQpl4hajqDjRxnKN/DQo=; b=aOF5A3Kj59aKxyzZyceP+Apaad3H7ahmwtjN62KQlObhuIrWYCl5Mz05qgEfV5LrPN /b8ECO737hVG0+pvvbi/lJX+EsBbTV23lQRawaGy7XmZ30H8WyNIK05sfbWQjwxVojNH Nb5Ob+AQwwtiGANJ7u8bCBdspIjFO7rPC1/KeXXIBAsDAymDj7JH3cjsRpXpxgXhHseu tVfBxlV8vVJIPQLhOZGnzcLPPyeaLYAgGZHzSCqvM3UOhbIYt5IFqPGQOseArwxOSolP cS9EmiblOYWo6Unz/MHoii+SYdGHBYlDFVFeuVMS/J4sQ8TuNVE6iICpM1yfVmwtmDPp Thiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=GfNYD/Eo98L+pHqqPXbFpUQXQpl4hajqDjRxnKN/DQo=; b=h4WomM0uY/5wAtJKi3HBW2MZz2VFgB1n6aDc9Up0rrx7SwhcruBd3w07YXorhwHXPE fG5pkZUe/e3Jtl5TPcqg3q7kY8PyWryIjg4gvr1k67L01NT1Wttv3zoLC0AuCkEBmKkB 1QHNAdZq7e2gZpRnmX89deHTO/ZMfw6jMJExGTR4pE2anoke3tMNmnjNlTapOlI/Veuq etOWUjbp1rEwAfyhcoHK4WQazmuHp1HLQmezB7cQKNMFa1xtcN1/m/WT3jtu9Oojo2P+ 044w9SSLvXj/cm+7Hb38trp09IQwJrc1gAFGKf38Mt6o3Ev+3n20objoIh9vWrh+sySP DqQw== X-Gm-Message-State: ANoB5plie/imzzBkGHc1a9h48ByrztOAJmtvnHSWYvMrYwTq2XNuIukJ A/+ZNxC+ZBX83nS/1psDd5LlwDkey3k= X-Google-Smtp-Source: AA0mqf6m4qJXdUKw9qlhWstQ9l6B00jZlneqVg4aOZ5o8HPdxDc+AeRUyG73rkliZOogvGh+a8ykbQ== X-Received: by 2002:a17:902:a406:b0:18f:a5fa:ca21 with SMTP id p6-20020a170902a40600b0018fa5faca21mr19512838plq.43.1671211183063; Fri, 16 Dec 2022 09:19:43 -0800 (PST) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id s12-20020a170902ea0c00b00179e1f08634sm1880943plg.222.2022.12.16.09.19.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Dec 2022 09:19:42 -0800 (PST) Message-ID: <0960fb32-094f-b75a-2157-f6c0816198cc@gmail.com> Date: Fri, 16 Dec 2022 10:19:41 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH v2] RISC-V: Produce better code with complex constants [PR95632] [PR106602] Content-Language: en-US To: gcc-patches@gcc.gnu.org, raphael Zinsly References: <20221209182510.43515-1-rzinsly@ventanamicro.com> From: Jeff Law In-Reply-To: <20221209182510.43515-1-rzinsly@ventanamicro.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,NICE_REPLY_A,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 12/9/22 11:25, Raphael Moreira Zinsly wrote: > Changes since v1: > - Fixed formatting issues. > - Added a name to the define_insn_and_split pattern. > - Set the target on the 'dg-do compile' in pr106602.c. > - Removed the rv32 restriction in pr95632.c. > > -- >8 -- > > Due to RISC-V limitations on operations with big constants combine > is failing to match such operations and is not being able to > produce optimal code as it keeps splitting them. By pretending we > can do those operations we can get more opportunities for > simplification of surrounding instructions. > > 2022-12-06 Raphael Moreira Zinsly > Jeff Law > > gcc/Changelog: > PR target/95632 > PR target/106602 > * config/riscv/riscv.md: New pattern to simulate complex > const_int loads. > > gcc/testsuite/ChangeLog: > * gcc.target/riscv/pr95632.c: New test. > * gcc.target/riscv/pr106602.c: New test. So I was doing a bit of testing around this. I think we need we're going to need a v3. The problem is at -O1 several passes do not run. In particular the post-loop CSE pass isn't run. That causes cse_not_expected to be set earlier in the pipeline which in turn means the new pattern is exposed to fwprop -- too early IMHO and with more potential to cause minor regressions as can be seen with riscv/load-immediate.c Given that bridge patterns are fairly standard and that combining, then resplitting has also become relatively standard (particularly for eliminating some data dependencies and late lowering) having a state variable to indicate that combine has started and such patterns should be exposed seems sensible. An alternate approach would be to do something more hackish like adding && flag_rerun_cse_after_loop to the condition. That's better than what we do now, but not as accurate as biting the bullet and making a state variable for combine. I'll cobble something together and test it. It'll require a wider test because it'll touch target independent files. Jeff