From patchwork Tue Dec 12 09:50:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiahao Xu X-Patchwork-Id: 177208 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7613424vqy; Tue, 12 Dec 2023 01:50:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsNSX7OuOGPl+2GbEGtqpNIdgAzfLcxY1ZiwlKx7lKshT5Pf89vKlg+w3ekwr6fxz4J6/w X-Received: by 2002:ac8:5d8d:0:b0:423:77e2:6fb6 with SMTP id d13-20020ac85d8d000000b0042377e26fb6mr9313670qtx.30.1702374657503; Tue, 12 Dec 2023 01:50:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702374657; cv=pass; d=google.com; s=arc-20160816; b=0NZhvPbSIgki1sJYT+HYItSZPJDymu2YniBzv1pg+UVFYdb9foGrnBwr4eUt6vG8rL LtZVuaGHSjK05g08iPrWDkZRII9tFVDARtA3EZI1cpRiQQ3jEGWtFBJnHwJWLLwujAcc or18aSAzskdSrERXB0axJ35ssIFHk4F1wuNffCvmth1SmGfARjozdgoyp+2Bqn5DOwI5 ShDcVBeFJqjLJi1k7Fg4RAyqEDT/MYj1QspbqUttJ5kDNpS+jvFmpw8ad0O6uc/72ngx haK87RBkZfZrx8UmW2iq9qW+OH7VzEaRvE+RHIiupKtEd0X3ORPbFYUFXKQA0V/rTia+ TAlQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:arc-filter :dmarc-filter:delivered-to; bh=+aAlaCQowUj33wCUUJGzVwmjHZoynPyc8XGsxmDexDY=; fh=w+xsGLuzpTj56E0bzPMCc39RWHkBXt2f2AGs+4pGimo=; b=AB8Qy2sdo0CGuCtP0yUz1LKg0lEvFoa7kSHxZy5ujbRjYM0ay18z+vxoPr2vI1vr+t F0mtCqFyPoByZ7DtdPsjrg+ybOtulSYYw6LkThfF/ZmcbICQBdoZCwzpCWTpI8EMhlME Szhtwvv3ad6+QI+O8mYdYuelPq/pUqkRry4hJA8iYYp5piO6T/GLe9Q0teaFTMntqFbK IojCDltgVN4tRSzTq8SbCc8ci08YCu5kEhmNpi5yskGZvI7kXeHDBwyQc2AaTNOrHBgX Y83cwMe1XSJYTPaGN2jBkqkHpjulzXfb7UKyOQBmoXsCmgS0pVsByDTD+QpBAV3GFlr4 SAtw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ex8-20020a05622a518800b00419642d586esi11160488qtb.450.2023.12.12.01.50.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 01:50:57 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3681A3857001 for ; Tue, 12 Dec 2023 09:50:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 9244E3858281 for ; Tue, 12 Dec 2023 09:50:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9244E3858281 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9244E3858281 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702374626; cv=none; b=iWZ5A8m5u+iHNhXBRG/rLP+a+IWWXD9jTQvDQYhqu5Y9pWN38OFjmBdfNyFVyXdKEDIn2JNf/x8ECuQMR6q9+p3lEiRoKQDiEHJpzSXJEgcsnjZ4P18m6rExbJV7fRy+3xWiB0eNVFAzCH3ABfFe2MHPKOsS/8ilIeeDd8o3SOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702374626; c=relaxed/simple; bh=y58Rf2dEHOfBl2ZagmjQVDzRNTnsu3aI4IKfvcXCZ94=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=cfbuIWcQwhfkWfbo+G6aiXeQUVclLUfe6NfoohAWURhnxg6YOOuz3qNJcr057QroinG2ckqrPyPw2+2RI6+IkmEbHV8iv9/C0sEmCOX9LmnGQ11NgRc107wXrFrSSIFhLg9EisyjBfYpm9680sQHbULRrPrMVlL0fg4AJP9bZi0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCzPA-00050G-Sa for gcc-patches@gcc.gnu.org; Tue, 12 Dec 2023 04:50:23 -0500 Received: from loongson.cn (unknown [10.10.130.252]) by gateway (Coremail) with SMTP id _____8AxJPDRLHhlYU4AAA--.1875S3; Tue, 12 Dec 2023 17:50:09 +0800 (CST) Received: from slurm-master.loongson.cn (unknown [10.10.130.252]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx3+HQLHhlv3AAAA--.3313S4; Tue, 12 Dec 2023 17:50:08 +0800 (CST) From: Jiahao Xu To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i@xen0n.name, chenglulu@loongson.cn, xuchenghua@loongson.cn, Jiahao Xu Subject: [PATCH] LoongArch: Define LOGICAL_OP_NON_SHORT_CIRCUIT. Date: Tue, 12 Dec 2023 17:50:06 +0800 Message-Id: <20231212095006.12830-1-xujiahao@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Cx3+HQLHhlv3AAAA--.3313S4 X-CM-SenderInfo: 50xmxthkdrqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7Zr4DKFWUKF45tFyDZFWrJFc_yoW8Ww1Up3 y7Zr1ktr48WFZxWw1qq3sxXw4Ivr17K3W29a4avr1xCr43JryUXF1vkF9xXF15Ja1xXr9a vr4S9w43Z3W0q3gCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07j8yCJUUUUU= Received-SPF: pass client-ip=114.242.206.163; envelope-from=xujiahao@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_FAIL, SPF_HELO_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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785069208370407763 X-GMAIL-MSGID: 1785069208370407763 Define LOGICAL_OP_NON_SHORT_CIRCUIT as 0, for a short-circuit branch, use the short-circuit operation instead of the non-short-circuit operation. This gives a 1.8% improvement in SPECCPU 2017 fprate on 3A6000. gcc/ChangeLog: * config/loongarch/loongarch.h (LOGICAL_OP_NON_SHORT_CIRCUIT): Define. gcc/testsuite/ChangeLog: * gcc.target/loongarch/short-circuit.c: New test. diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h index f1350b6048f..880c576c35b 100644 --- a/gcc/config/loongarch/loongarch.h +++ b/gcc/config/loongarch/loongarch.h @@ -869,6 +869,7 @@ typedef struct { 1 is the default; other values are interpreted relative to that. */ #define BRANCH_COST(speed_p, predictable_p) loongarch_branch_cost +#define LOGICAL_OP_NON_SHORT_CIRCUIT 0 /* Return the asm template for a conditional branch instruction. OPCODE is the opcode's mnemonic and OPERANDS is the asm template for diff --git a/gcc/testsuite/gcc.target/loongarch/short-circuit.c b/gcc/testsuite/gcc.target/loongarch/short-circuit.c new file mode 100644 index 00000000000..2cef0193466 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/short-circuit.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-gimple" } */ + +int +short_circuit (float *a) +{ + float t1x = a[0]; + float t2x = a[1]; + float t1y = a[2]; + float t2y = a[3]; + float t1z = a[4]; + float t2z = a[5]; + + if (t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) + return 0; + + return 1; +} +/* { dg-final { scan-tree-dump-times "if" 6 "gimple" } } */