From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 5F1783857B98 for ; Thu, 3 Aug 2023 20:19:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F1783857B98 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-pl1-x62b.google.com with SMTP id d9443c01a7336-1bbf8cb694aso11759855ad.3 for ; Thu, 03 Aug 2023 13:19:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691093974; x=1691698774; h=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=Cw7dV+QplHxIsuwXMCaVhI6GSzxWEumi2sUf5Bn71iw=; b=fzJ87123OgBrSfFAzYi9NJIB6tbbxxnDDSsZPUugY+INNTsBopJPz7Addqo5y4/lcY oqDIOw/dIzV8oLmVBREmUPkYi11A9/OSyoUkc2kG0VqlCPlgeh5D3QZSFfnsZVq43MO7 0d/l6zgjWUR0/pWW93GQllz+bhQKHd430sO81T6ip6TKkqq3PIT3XFR40/fEtLiNnzG8 qZ0O2NddIl7mSKnh9iSZb/uIqnbIIpz+Xrob51dNUqTlrQwpcxjHNyusLLBpm5uPz6dg oI823ms8WQM47bMvLClecP9KyJzCE7T8YnQWBK1KooM82R5vge7Vv13cpQUt2q3G7kEB vnKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691093974; x=1691698774; h=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=Cw7dV+QplHxIsuwXMCaVhI6GSzxWEumi2sUf5Bn71iw=; b=PyCfjkaar4Kb3DWXQUBg9I3fyqxtUzEgQAvtl7QQnpWttAKyUUUENyrYeJdEDBRZ4P PaqvqM45hmYspHlaMM4nki/4iooQvJmsJDUPiYXgwWKvcHAl7KPV8U09rVfCW/CKOCJq pqn9gf/0WqhW+YdL5cewQYk0Ie/pAsUzzOeJiEZRNfapb1xNKkNEAMA0fKHr1ZP+qh0M CLia5AvRPMJBeL3mjR3pbdVq6Kj/2Mb7U+3rZBddz2MzUVE3xA8UIT89XwdmH3mT24Hm vs1piSNByHRUwOK96r3iCRHffFstUpBCy/B4N2/IeKIc/Dk39TJoAhkr2aWTxDB8vOCI Srdw== X-Gm-Message-State: ABy/qLZy1Y4y/1sl+9HM6l+8PbmcPileJPeETA/O6PiOY36hSOkYKMdA J2A5Vc+eATunflKN/CjO+vw= X-Google-Smtp-Source: APBJJlHX0B3HM446VOaaDChPaKsBB0TqXMt0wzyALqPbpEPN+f3EZY6/8izdnAs4okuZzNl/kBgewg== X-Received: by 2002:a17:902:ea09:b0:1b8:76ce:9d91 with SMTP id s9-20020a170902ea0900b001b876ce9d91mr24122331plg.1.1691093974214; Thu, 03 Aug 2023 13:19:34 -0700 (PDT) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id w21-20020a170902a71500b001b558c37f91sm240964plq.288.2023.08.03.13.19.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Aug 2023 13:19:33 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------tyYAUHKmWljlU8L4eF0MqFnM" Message-ID: <73fd9259-ba08-1ae9-f302-951e8ac385b4@gmail.com> Date: Thu, 3 Aug 2023 14:19:32 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v3] [RISC-V] Generate Zicond instruction for select pattern with condition eq or neq to 0 Content-Language: en-US To: Xiao Zeng Cc: gcc-patches@gcc.gnu.org, research_trasio@irq.a4lg.com, kito.cheng@gmail.com, zhengyu@eswincomputing.com, eri-sw-toolchain@eswincomputing.com References: <20230802013813.14284-1-zengxiao@eswincomputing.com> From: Jeff Law In-Reply-To: <20230802013813.14284-1-zengxiao@eswincomputing.com> X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_NUMSUBJECT,KAM_SHORT,NICE_REPLY_A,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: This is a multi-part message in MIME format. --------------tyYAUHKmWljlU8L4eF0MqFnM Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 8/1/23 19:38, Xiao Zeng wrote: > This patch recognizes Zicond patterns when the select pattern > with condition eq or neq to 0 (using eq as an example), namely: > > 1 rd = (rs2 == 0) ? non-imm : 0 > 2 rd = (rs2 == 0) ? non-imm : non-imm > 3 rd = (rs2 == 0) ? reg : non-imm > 4 rd = (rs2 == 0) ? reg : reg > > gcc/ChangeLog: > > * config/riscv/riscv.cc (riscv_expand_conditional_move): Recognize > Zicond patterns > * config/riscv/riscv.md: Recognize Zicond patterns through movcc > > gcc/testsuite/ChangeLog: > > * gcc.target/riscv/zicond-primitiveSemantics_return_0_imm.c: New test. > * gcc.target/riscv/zicond-primitiveSemantics_return_imm_imm.c: New test. > * gcc.target/riscv/zicond-primitiveSemantics_return_imm_reg.c: New test. > * gcc.target/riscv/zicond-primitiveSemantics_return_reg_reg.c: New test. So I've done a partial commit of this patch. I'm still evaluating a few of the cases and haven't included them yet. The most notable change I've made is the 0, imm case and imm, 0 case can trivially handle 0, reg and reg, 0 as well. I also changed the imm, imm case to use gen_int_mode rather than GEN_INT. It may not be strictly necessary here, but it does future proof the code a bit if we were to support additional mode (and we may well want to do that). I'm hoping to get the rest of patch #3 in today, though I suspect the testing will push it into tomorrow. Then I want to layer on Raphael's code to handle missed cases using scc insns. Jeff --------------tyYAUHKmWljlU8L4eF0MqFnM Content-Type: text/plain; charset=UTF-8; name="P" Content-Disposition: attachment; filename="P" Content-Transfer-Encoding: base64 Y29tbWl0IDllM2ZkMzMyOTU5OTMwZWZkM2NhYmYyMjJhZmJhYzkxMDUwN2QyZjMKQXV0aG9y OiBYaWFvIFplbmcgPHplbmd4aWFvQGVzd2luY29tcHV0aW5nLmNvbT4KRGF0ZTogICBUaHUg QXVnIDMgMTY6MDk6NDYgMjAyMyAtMDQwMAoKICAgIFtQQVRDSCAzLzVdIFtSSVNDLVZdIEdl bmVyYXRlIFppY29uZCBpbnN0cnVjdGlvbiBmb3Igc2VsZWN0IHBhdHRlcm4gd2l0aCBjb25k aXRpb24gZXEgb3IgbmVxIHRvIDAKICAgIAogICAgWyBUaGlzIGlzIGEgcGFydGlhbCBjb21t aXQuICBTbyBub3QgYWxsIHRoZSBjYXNlcyBtZW50aW9uZWQgYnkKICAgICAgWGlhbyBhcmUg Y3VycmVudGx5IGhhbmRsZWQuIF0KICAgIAogICAgVGhpcyBwYXRjaCByZWNvZ25pemVzIFpp Y29uZCBwYXR0ZXJucyB3aGVuIHRoZSBzZWxlY3QgcGF0dGVybgogICAgd2l0aCBjb25kaXRp b24gZXEgb3IgbmVxIHRvIDAgKHVzaW5nIGVxIGFzIGFuIGV4YW1wbGUpLCBuYW1lbHk6CiAg ICAKICAgIDEgcmQgPSAocnMyID09IDApID8gbm9uLWltbSA6IDAKICAgIDIgcmQgPSAocnMy ID09IDApID8gbm9uLWltbSA6IG5vbi1pbW0KICAgIDMgcmQgPSAocnMyID09IDApID8gcmVn IDogbm9uLWltbQogICAgNCByZCA9IChyczIgPT0gMCkgPyByZWcgOiByZWcKICAgIAogICAg Z2NjL0NoYW5nZUxvZz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KKwkgdGhpbmtpbmcgaXQgaXMgdW5uZWNlc3Nhcnku ICBXZSBtaWdodCBjb25zaWRlciB1c2luZworCSByaXNjdl9leHRlbmRfb3BlcmFuZHMgaWYg dGhleSBhcmUgbm90IGFscmVhZHkgcHJvcGVybHkgZXh0ZW5kZWQuICAqLworICAgICAgaWYg KEdFVF9NT0RFIChvcDApICE9IHdvcmRfbW9kZSB8fCBHRVRfTU9ERSAob3AxKSAhPSB3b3Jk X21vZGUpCisJcmV0dXJuIGZhbHNlOworCisgICAgICAvKiAwLCByZWcgb3IgMCwgaW1tICov CisgICAgICBpZiAoY29ucyA9PSBDT05TVDBfUlRYIChtb2RlKQorCSAgJiYgKFJFR19QIChh bHQpCisJICAgICAgfHwgKENPTlNUX0lOVF9QIChhbHQpICYmIGFsdCAhPSBDT05TVDBfUlRY IChtb2RlKSkpKQorCXsKKwkgIHJpc2N2X2VtaXRfaW50X2NvbXBhcmUgKCZjb2RlLCAmb3Aw LCAmb3AxLCB0cnVlKTsKKwkgIHJ0eCBjb25kID0gZ2VuX3J0eF9mbXRfZWUgKGNvZGUsIEdF VF9NT0RFIChvcDApLCBvcDAsIG9wMSk7CisJICBhbHQgPSBmb3JjZV9yZWcgKG1vZGUsIGFs dCk7CisJICBlbWl0X2luc24gKGdlbl9ydHhfU0VUIChkZXN0LAorCQkJCSAgZ2VuX3J0eF9J Rl9USEVOX0VMU0UgKG1vZGUsIGNvbmQsCisJCQkJCQkJY29ucywgYWx0KSkpOworCSAgcmV0 dXJuIHRydWU7CisJfQorICAgICAgLyogaW1tLCBpbW0gKi8KKyAgICAgIGVsc2UgaWYgKENP TlNUX0lOVF9QIChjb25zKSAmJiBjb25zICE9IENPTlNUMF9SVFggKG1vZGUpCisJICAgICAg ICYmIENPTlNUX0lOVF9QIChhbHQpICYmIGFsdCAhPSBDT05TVDBfUlRYIChtb2RlKSkKKwl7 CisJICByaXNjdl9lbWl0X2ludF9jb21wYXJlICgmY29kZSwgJm9wMCwgJm9wMSw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