From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 8BEBD3858D3C for ; Mon, 14 Nov 2022 16:06:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8BEBD3858D3C 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-x1030.google.com with SMTP id m6-20020a17090a5a4600b00212f8dffec9so11125407pji.0 for ; Mon, 14 Nov 2022 08:06:14 -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:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=J3rghMgplIX+ped+NRDiFYLwAbanX/cB6piQ+Nl50tY=; b=LJB+n2FVwixsqCDy/oQckovqEvYXAzXxI7KJM22prTZMQcIv4C2+uPdPm+QtCi8LHG 5o47w01coGkVTittTC262hrBJlJk4gRsllQlVw2Py6Be7fbgwSb/36kFoh5sCXu+LSAe 6Zs0i61N3MqZpwTwP7AXqqK5cTiC+lxU57HAokgwAm82TvWhF7OhVa4WIchlszB1EMhD keynSIAsAOv5wlQBf6ZEJKMUkjCdL8F9giHg4QKkZ4ukLjUoD2S5z/ZGGgkS1919KFms Db4cvx2atvnc1BuoZ97Dv1NIlTiJ8n7CgjlyLxai1w2fwy/6IjO6sqjd/bOhLiw6G19a 2TWQ== 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: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=J3rghMgplIX+ped+NRDiFYLwAbanX/cB6piQ+Nl50tY=; b=2TJOCfSquLuW/DkKRbq+sgwt2dwBBLgsYgH3GXNcXPvV9kGtTqCizEK2hR6Yg4wlOb fFdlZ/7NcDx4Om+FSlG2pDbNUoM7rIVBV8ZRw2HxSeMiOzpNb/8bKr5iBytE5iBAR974 ismljxgaE/ELZe/Z32nW3LuscGz3rMrZsFGhD7VYA3S3ywk8c2K0hvbmQ08EPE/xDXwM Gpa5DXSs1AZY9afJHXdDwqwyLfHQXakaXowQMk+WysZMNX1w6FLqo5fKtMlo7OFe5G5f AGBtHCl8muZJcrvFB6CmgaYSPKbVAh9uC4biBvjPVWr+qyOM901WEknEmZ5pycUCSH1e 9sLQ== X-Gm-Message-State: ANoB5pn2dzZ7XQ6DTAKvoSTIwMRcRyQH2tlCYpYDwcYi6jYA2ZTKc1zn 0WWG+yUMZHQEFZUCQ/kBcv0= X-Google-Smtp-Source: AA0mqf5uOJwjEvmPFK/HPofzFV7qTea6veByzU0GyWEnp+eKtFCkgXp0MWB1D2t6gWtgEX8h38dRww== X-Received: by 2002:a17:903:4c2:b0:186:880c:167e with SMTP id jm2-20020a17090304c200b00186880c167emr68613plb.7.1668441973264; Mon, 14 Nov 2022 08:06:13 -0800 (PST) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id u190-20020a6260c7000000b0056b8b17f914sm6864421pfb.216.2022.11.14.08.06.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Nov 2022 08:06:12 -0800 (PST) Message-ID: Date: Mon, 14 Nov 2022 09:06:10 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH v2 2/2] RISC-V: Add instruction fusion (for ventana-vt1) Content-Language: en-US To: Philipp Tomsich , gcc-patches@gcc.gnu.org Cc: Palmer Dabbelt , Vineet Gupta , Jeff Law , Kito Cheng , Christoph Muellner References: <20221113204824.4062042-1-philipp.tomsich@vrull.eu> <20221113204824.4062042-3-philipp.tomsich@vrull.eu> From: Jeff Law In-Reply-To: <20221113204824.4062042-3-philipp.tomsich@vrull.eu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,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 11/13/22 13:48, Philipp Tomsich wrote: > The Ventana VT1 core supports quad-issue and instruction fusion. > This implemented TARGET_SCHED_MACRO_FUSION_P to keep fusible sequences > together and adds idiom matcheing for the supported fusion cases. > > gcc/ChangeLog: > > * config/riscv/riscv.cc (enum riscv_fusion_pairs): Add symbolic > constants to identify supported fusion patterns. > (struct riscv_tune_param): Add fusible_op field. > (riscv_macro_fusion_p): Implement. > (riscv_fusion_enabled_p): Implement. > (riscv_macro_fusion_pair_p): Implement and recoginze fusible > idioms for Ventana VT1. > (TARGET_SCHED_MACRO_FUSION_P): Point to riscv_macro_fusion_p. > (TARGET_SCHED_MACRO_FUSION_PAIR_P): Point to riscv_macro_fusion_pair_p. You know the fusion rules for VT1 better than I...  I'm happy to largely defer to you on this. I do wonder if going forward hand matching RTL like this is going to be an unmaintainable mess and whether or not we would be better served using insn attributes to describe instruction fusion. > > Signed-off-by: Philipp Tomsich > --- > > Changes in v2: > - Update fusion patterns and catch some missing idioms/fusion pairs. > > gcc/config/riscv/riscv.cc | 219 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 219 insertions(+) > > diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc > index 31d651f8744..43ba520885c 100644 > --- a/gcc/config/riscv/riscv.cc > +++ b/gcc/config/riscv/riscv.cc > > +static bool > +riscv_macro_fusion_pair_p (rtx_insn *prev, rtx_insn *curr) > +{ > + rtx prev_set = single_set (prev); > + rtx curr_set = single_set (curr); > + /* prev and curr are simple SET insns i.e. no flag setting or branching. */ > + bool simple_sets_p = prev_set && curr_set && !any_condjump_p (curr); > + > + if (!riscv_macro_fusion_p ()) > + return false; > + > + if (simple_sets_p && (riscv_fusion_enabled_p (RISCV_FUSE_ZEXTW) || > + riscv_fusion_enabled_p (RISCV_FUSE_ZEXTH))) Formatting nit.  Bring the && down to a new line and if you still need a line break for the "||",  then the "||" should be on a new line as well.  Something like this... if (simple_sets_p       && (riscv_fusion_enabled_p (RISCV_FUSE_ZEXTW           || riscv_fusion_enabled_p (RISCV_FUSE_ZEXTH))) > + && REGNO (XEXP (SET_SRC (curr_set), 0)) == REGNO(SET_DEST (curr_set)) Space before open paren on this line. > > + && (( INTVAL (XEXP (SET_SRC (curr_set), 1)) == 32 > + && riscv_fusion_enabled_p(RISCV_FUSE_ZEXTW) ) > + || ( INTVAL (XEXP (SET_SRC (curr_set), 1)) < 32 > + && riscv_fusion_enabled_p(RISCV_FUSE_ZEXTWS)))) Extraneous spaces after the open parens before INTVALs above. > + && REGNO (XEXP (SET_SRC (curr_set), 0)) == REGNO(SET_DEST (curr_set)) Missing whitespace before open paren on this line. OK with the nits fixed. Jeff