From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7877) id B6ADF3858C53; Fri, 26 Jan 2024 08:13:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6ADF3858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706256801; bh=dW5TCFIUBa3lqWPOl1fI/cpCSyXkYXZoaAgMyKTRBAw=; h=From:To:Subject:Date:From; b=K/XBVxyIzi3YzE3BFKAlFn8NPXhGdnx456DmB9xF61Y5I9GIl7nQcKwt8C4lVeoDy E+Y8hm5owgViSvCbV6esVUHAyokbe5U0d/b0UUGPCUz2VWUEu9ohbKjRBghLQSQRR/ 234AyUXZNKeCifho4IqBzB6jqHAIlGkSb2n1RFT0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: LuluCheng To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8446] LoongArch: Define LOGICAL_OP_NON_SHORT_CIRCUIT X-Act-Checkin: gcc X-Git-Author: Jiahao Xu X-Git-Refname: refs/heads/master X-Git-Oldrev: 9e7947a66737c43cdec026b1f9c8149c5eba6c40 X-Git-Newrev: dddafe948230b4895f8d4371eee7996fb2dba44a Message-Id: <20240126081321.B6ADF3858C53@sourceware.org> Date: Fri, 26 Jan 2024 08:13:21 +0000 (GMT) List-Id: https://gcc.gnu.org/g:dddafe948230b4895f8d4371eee7996fb2dba44a commit r14-8446-gdddafe948230b4895f8d4371eee7996fb2dba44a Author: Jiahao Xu Date: Tue Jan 16 10:32:31 2024 +0800 LoongArch: Define LOGICAL_OP_NON_SHORT_CIRCUIT 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. This modification will introduce the following FAIL items: FAIL: gcc.dg/tree-ssa/copy-headers-8.c scan-tree-dump-times ch2 "Conditional combines static and invariant" 1 FAIL: gcc.dg/tree-ssa/copy-headers-8.c scan-tree-dump-times ch2 "Will duplicate bb" 2 FAIL: gcc.dg/tree-ssa/update-threading.c scan-tree-dump-times optimized "Invalid sum" 0 gcc/ChangeLog: * config/loongarch/loongarch.h (LOGICAL_OP_NON_SHORT_CIRCUIT): Define. gcc/testsuite/ChangeLog: * gcc.target/loongarch/short-circuit.c: New test. Diff: --- gcc/config/loongarch/loongarch.h | 1 + gcc/testsuite/gcc.target/loongarch/short-circuit.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h index 4e6ede926d32..8b453ab3140d 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 000000000000..bed585ee1728 --- /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" } } */