From patchwork Tue Jan 16 02:32:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiahao Xu X-Patchwork-Id: 188366 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp11058dye; Mon, 15 Jan 2024 18:33:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGarEJ3Z4tqNbXtk7R7cPGlFGt4xBhj6M37hs1UjuGNg1R7CpgJDLHdZ7MYhU3OFegPvoCW X-Received: by 2002:a05:622a:211:b0:429:c908:109c with SMTP id b17-20020a05622a021100b00429c908109cmr6627264qtx.89.1705372407969; Mon, 15 Jan 2024 18:33:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705372407; cv=pass; d=google.com; s=arc-20160816; b=Ms/6+NtqU0fHjjbtfXIHxvJ6Kr5Ms5jKTKVe2/lOpvLsPIyo4gOHbHzullKbozWRNb mYbROOqmFA30oq8+Mr5Uc6VI2gWB65afUYF4L/jAwvf11vgGGHh7Tcgb7XpzueY2BJ25 0iv2/lwsCNjjnF+UnjaX2mFTqt+HQl97b1LcjqpJfTRPm5tZGJuc0Ngdp1mqTA36wDuR PBIymTxeQ9GKWv4+lvMQtx4VPVVn8DWc4ftQAWXzK4B35K4QOcavRaeUR6i4YFbp+E3h Pi8Po5FWhHwfB/PcEVqc/9VWVsokw8hkskekFiWNghuZbawqqRJfCQK1zrAYx1ES0sT7 uIcw== 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=jrD0GTmIpOncXEFC7HUdV7oJqgLcMTzFur12xweSdMg=; fh=w+xsGLuzpTj56E0bzPMCc39RWHkBXt2f2AGs+4pGimo=; b=NGMGAseIhbWB4CVPndg7PAAryZNBvQE0l7XhvsmIE3Fl7bBU+M8+qIAdbIaRZrm8hP eDJfHUoMdqw4Pe1IGWqvI0QDYhlcuARa58twPpYmYyvoZmpMxmyb9l7CjuDgcjYUEvbs InC3OctQw9ukrRAbWdlPvZ/tiuxo+Y7++3Mw6MaM+3qA3COSbZqbRQ3zg8Yppd8eH3TR KeqStYMt3FAeGTqX/fwt7Wy+fWDg69gsV2XmZzM44ucYkEF2NZzQ05tnRPuPKhQeszHB AfCk3JaRn2qCAVLIXjr4XCHmhZxUD00niwa2UReU55BUD/5IqkNrPhCMdl030/K5c0mn fx6w== 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 q22-20020a05622a031600b00429fba5e313si1652147qtw.347.2024.01.15.18.33.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 18:33:27 -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 AB9ED3858408 for ; Tue, 16 Jan 2024 02:33:27 +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 E56613858D1E for ; Tue, 16 Jan 2024 02:32:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E56613858D1E 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 E56613858D1E 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=1705372360; cv=none; b=d7Bo1LQpFO5yusHBqAVNbOYoPj3uNk2wiZe9gHfL5dD1wDZIBOiSR7ZUiD2WK+8X3BQXv0HeDXrigMrInm2zCUSxs/Wal/Fu8NAnrGmBJfODQVME1J89US9LWnsbHnFgduWXy00S9zqwti3zstVRNBQnu9fhW1ZP2CQKn0qS9Uw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705372360; c=relaxed/simple; bh=dd3QrfbKca0XIkpnTHut286E1MDMFGOZljfBm59qqqQ=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=dSa1DEJWZFkpPttNngDm1Wuyks+MXbIj6Kxvysk/7TKgP9GmstCXWghC8nv1hu9UEPMP8QwQNj8Wely7eqFor17IwP0m6lVLhj2ZEQIQcgenfj4BgRllP6G6PuEV70RWRUt8zMi5udxBu6ivWwXT48OnfjGPvfMSoj7kYsMKh58= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.10.130.252]) by gateway (Coremail) with SMTP id _____8DxWPDB6qVlB40AAA--.2703S3; Tue, 16 Jan 2024 10:32:33 +0800 (CST) Received: from slurm-master.loongson.cn (unknown [10.10.130.252]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxTs3A6qVlvR8DAA--.14247S4; Tue, 16 Jan 2024 10:32:32 +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 v3] LoongArch: Define LOGICAL_OP_NON_SHORT_CIRCUIT Date: Tue, 16 Jan 2024 10:32:31 +0800 Message-Id: <20240116023231.53164-1-xujiahao@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8AxTs3A6qVlvR8DAA--.14247S4 X-CM-SenderInfo: 50xmxthkdrqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7Zr4DKFWUKF45uFWUAFy8Xrc_yoW8AFW3p3 y7Ar1ktr48WFZxWw4qq3s3Xw47Zr17Kw12va4SvryxCr43JryUXF1kKrnxXF15Ja1xZr9I vr4S9w4ava4Fq3gCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUAVWUtwAv7VC2z280aVAF wI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxUwMKuUUUUU X-Spam-Status: No, score=-13.2 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: 1788212578074473965 X-GMAIL-MSGID: 1788212578074473965 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. SPEC2017 performance evaluation shows 1% performance improvement for fprate GEOMEAN and no obvious regression for others. Especially, 526.blender_r +10.6% 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 4e6ede926d3..8b453ab3140 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) la_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" } } */