From patchwork Tue Dec 12 11:14:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiahao Xu X-Patchwork-Id: 177261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7649419vqy; Tue, 12 Dec 2023 03:14:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYrNZFzRZl8sCdIrIP3Nugrs3+q2sTLyiXRYZGyLYNO8zki2NkzM6sT95Qj/39dN0VFUbR X-Received: by 2002:a05:620a:21d8:b0:77f:3a4:48f6 with SMTP id h24-20020a05620a21d800b0077f03a448f6mr7193220qka.56.1702379681788; Tue, 12 Dec 2023 03:14:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702379681; cv=pass; d=google.com; s=arc-20160816; b=t6ibmTgDnCGim4M2Ljh0ZUHwZ+sMGz0UczHBZjCL58Hh4gPh1Ml7OPSl9wKXQfsYYo JILrBakrVP0PlKwGEwakF9jeLlr7qtAuyHuTikNXcz+S2LyN4nbFqxHzbWmKtplqsFg9 1hWEwp1q78cRJhaMKmL4OpjD0b53rlj5Zxr9fe0526dyKWL59SY/6MsJ0DZuguOCZBo7 fRaJpPSvd0XLDXv19zw7BkQTQ7CwzJljv9U6nP8VwRf6Gr8c1pbSG3OFneFdRKu00sJG goYVrCC2SJyIInc4qqYNKh5QoNCS8bzotQHQywOY/kdtcaIoalVek5Kks9PWmy7NJgK1 22xg== 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=wOxaKILhQZp2aFvrbd314/3cjo42Uf4BmosdjbB5htk=; fh=w+xsGLuzpTj56E0bzPMCc39RWHkBXt2f2AGs+4pGimo=; b=u7MGFF8qYUlG9/0slTYon5u7HsoDvCLpP2InB0gMQAKqZMqqk3J1XSUjqXbcD2eiYK jqM7OJ3+m5OYdkZsXXOn67+LvXq6Xwtb3yQLWAVZt3i5hbSaZlqBiRRn/ZK4an84yKoN V6c5ut1jwHSprEPnU3k5blzNP/pzU+Rs2JMMZO4ZVzHhxamrzgEKtcV2MgvSiQ1IvT88 nwW40WU6yheYZ2eiH0+qtkfnTR5F4LbhvhfGUA0NiObtvh/kjGoLG3D0Iphn84qVsBqG UKThO7IOJ4GRjDy1OhrrIqF05S3q+ptgurMTDTd8PJkaSge43+k+tGhQMi3tvKNEJJKf 2f+A== 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 k10-20020a05620a414a00b00773eb4de2c7si11008348qko.257.2023.12.12.03.14.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 03:14:41 -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 8BA57385735A for ; Tue, 12 Dec 2023 11:14:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 9E9893858418 for ; Tue, 12 Dec 2023 11:14:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E9893858418 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9E9893858418 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702379659; cv=none; b=RXGNZuw+T4AkM2JqGWEwFFgGDKRTI4u23Rev7Am/CdSUdWBsL26X8Ub0CFI9fn+pXv14vGlMp6RPSW8U/dxDMl+Ekcs5TIvNyQcwMfx6CUiAzqqLwr7grpB/pdIh7A4BoKLM/HIkJXPqdon1+LcwKeMiX2OdE781PZ352xep7Fw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702379659; c=relaxed/simple; bh=vhWHMKCCq8Y87/gxFz2ctXNeEpFplVxoJubrrdLxgpQ=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=elZPMjjvalpsrQGow8YQY+ugO8b2Za32aipsc7INpVt5Qe9U/7HqItKSG39vFCo1HUzFj/5DPp4INOIBCTc6mvq7RaO/SKsUS0DJpd0nsFBzagTFgrjGHz7rE6k59EU7qqh9QGvUb7BmdD55Fk52N8hzRgQ304T0P60X87LBy7s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.10.130.252]) by gateway (Coremail) with SMTP id _____8DxyeiGQHhlflIAAA--.2015S3; Tue, 12 Dec 2023 19:14:15 +0800 (CST) Received: from slurm-master.loongson.cn (unknown [10.10.130.252]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxXeGGQHhlrIMAAA--.3781S4; Tue, 12 Dec 2023 19:14:14 +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 v2] LoongArch: Define LOGICAL_OP_NON_SHORT_CIRCUIT. Date: Tue, 12 Dec 2023 19:14:12 +0800 Message-Id: <20231212111412.29351-1-xujiahao@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxXeGGQHhlrIMAAA--.3781S4 X-CM-SenderInfo: 50xmxthkdrqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7Zr4DKFWUKF45tFyDZFWrJFc_yoW8Ww48p3 y7Ar1ktr48WFZxWw1qq3sxXw4Ivry7K3W29a4Svr1xCr43JryUZF1vkr9xXF15Ja1xXr9a vr4F9w4av3W0q3gCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07URa0PUUUUU= X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, 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 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: 1785074477205228798 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..bed585ee172 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/short-circuit.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math -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" } } */