From patchwork Wed Sep 4 05:43:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Lin1" X-Patchwork-Id: 97030 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 183CE386100A for ; Wed, 4 Sep 2024 05:44:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by sourceware.org (Postfix) with ESMTPS id A5617385C6D1 for ; Wed, 4 Sep 2024 05:44:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A5617385C6D1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A5617385C6D1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725428643; cv=none; b=ASgOKUAXefKyz35r/ADlHRhWM0ucNuuEPhcOsl82vX67QHufWrnYqlY4rdqoU8bXyK+KB13/Ex00VBMQWIcX1SRQk7Z7MS6SWhPrJ7RKfX8aSwKzCQHLBJvqz06ld2q8SS1vddwpiihlDPLgAujGfrKl+xtd0XuF/YE7f/g3tUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725428643; c=relaxed/simple; bh=tpYhGV/wJ2kd77Ns3Err0EpTSwHH5wi6L3m9LKz5f+M=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=j42JtlyJW4xy5c7vNqpTWjLcryoUidsbvgzJlmMR+SOkpP4nEBQaSLUVtVogO1ZCOPcCeUiZFHsvE1VR55o4/PUtD3D1cR4AVAxsUZTcS7kUUNrHLmDbTfo69LRFCrVv/wFmH/9wxFFZSIIiivnf7NBpw8MLD350GuDygqNv0zg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725428641; x=1756964641; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tpYhGV/wJ2kd77Ns3Err0EpTSwHH5wi6L3m9LKz5f+M=; b=aRhF+FjxLRgrOgSlLkEfNnZkDnpkjUNAcgIRoK7vhnqDwXM0JEUYmCi8 +griVZldkmG5KNrw3NHy8/EJ+6EfCqRdrAMwyOwwIWB7H4K9xzGXnVjJ9 09s866UVfBx9F673/Hz6ZIwvNf/8lxqo/WbRKhMgSiuqO+4SnGVo6KMco xH7447cbGZDbWL5cFN90hTs2wodOVtBy8qlmuojEmmm+Hu/yJ5YfKad2a BxaOlVfBAa8KBadcz2tuFepUn9JCJiUR3TU9zinfi4ZpxHlFs5hDIgaGS +zc1X9xaNGysoLOzGFyn7IHzzbsnbhOiJXZp10m+SMJntZY04ls9PlwpV Q==; X-CSE-ConnectionGUID: xAvoL/DCQoSnf6eHKuyy0Q== X-CSE-MsgGUID: iJdDtgy2RCyZVRhQhuJzGQ== X-IronPort-AV: E=McAfee;i="6700,10204,11184"; a="24252995" X-IronPort-AV: E=Sophos;i="6.10,200,1719903600"; d="scan'208";a="24252995" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2024 22:43:59 -0700 X-CSE-ConnectionGUID: BbSwJE0SQLC/geNy/G8LTA== X-CSE-MsgGUID: 35U6djzcS1S4GzCPAv7N+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,201,1719903600"; d="scan'208";a="64834434" Received: from shliclel4214.sh.intel.com ([10.239.240.214]) by fmviesa007.fm.intel.com with ESMTP; 03 Sep 2024 22:43:46 -0700 From: "Hu, Lin1" To: gcc-patches@gcc.gnu.org Cc: hontao.liu@intel.com, ubizjak@gmail.com, rguenther@suse.de, jakub@redhat.com, pinskia@gmail.com Subject: [PATCH] Match: Fix ordered and nonequal Date: Wed, 4 Sep 2024 13:43:45 +0800 Message-Id: <20240904054345.1827642-1-lin1.hu@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, 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~patchwork=sourceware.org@gcc.gnu.org Hi, all This patch is a fix patch. Need to add :c for bit_and, because bit_and is commutative. And is (ltgt @0 @1) is simpler than (bit_not (uneq @0 @1)). Bootstrapped/regtested on x86-64-pc-linux-gnu, OK for trunk? BRs, Lin gcc/ChangeLog: * match.pd: Fix match for (bit_and (ordered @0 @1) (ne @0 @1)). gcc/testsuite/ChangeLog: * gcc.dg/opt-ordered-and-nonequal-1.c: New test. * gcc.target/i386/optimize_one.c: Change name to opt-comi-1.c. * gcc.target/i386/opt-comi-1.c: New test. --- gcc/match.pd | 4 +- .../gcc.dg/opt-ordered-and-nonequal-1.c | 49 +++++++++++++++++++ gcc/testsuite/gcc.target/i386/opt-comi-1.c | 49 +++++++++++++++++++ gcc/testsuite/gcc.target/i386/optimize_one.c | 9 ---- 4 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/opt-ordered-and-nonequal-1.c create mode 100644 gcc/testsuite/gcc.target/i386/opt-comi-1.c delete mode 100644 gcc/testsuite/gcc.target/i386/optimize_one.c diff --git a/gcc/match.pd b/gcc/match.pd index 4298e89dad6..621306213e4 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -6652,8 +6652,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (!flag_trapping_math || !tree_expr_maybe_nan_p (@0)) { constant_boolean_node (false, type); })) (simplify - (bit_and (ordered @0 @1) (ne @0 @1)) - (bit_not (uneq @0 @1))) + (bit_and:c (ordered @0 @1) (ne @0 @1)) + (ltgt @0 @1)) /* x == ~x -> false */ /* x != ~x -> true */ diff --git a/gcc/testsuite/gcc.dg/opt-ordered-and-nonequal-1.c b/gcc/testsuite/gcc.dg/opt-ordered-and-nonequal-1.c new file mode 100644 index 00000000000..6d102c2bd0c --- /dev/null +++ b/gcc/testsuite/gcc.dg/opt-ordered-and-nonequal-1.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop1-details" } */ + +int is_ordered_and_nonequal_sh_1 (float a, float b) +{ + return !__builtin_isunordered (a, b) && (a != b); +} + +int is_ordered_and_nonequal_sh_2 (float a, float b) +{ + return !__builtin_isunordered (a, b) && (b != a); +} + +int is_ordered_and_nonequal_sh_3 (float a, float b) +{ + return (b != a) && !__builtin_isunordered (a, b); +} + +int is_ordered_and_nonequal_sh_4 (float a, float b) +{ + return !__builtin_isunordered (a, b) && !(a == b); +} + +int is_ordered_and_nonequal_sh_5 (float a, float b) +{ + return !__builtin_isunordered (a, b) && !(b == a); +} + +int is_ordered_and_nonequal_sh_6 (float a, float b) +{ + return !(b == a) && !__builtin_isunordered (a, b); +} + +int is_ordered_or_nonequal_sh_7 (float a, float b) +{ + return !(__builtin_isunordered (a, b) || (a == b)); +} + +int is_ordered_or_nonequal_sh_8 (float a, float b) +{ + return !(__builtin_isunordered (a, b) || (b == a)); +} + +int is_ordered_or_nonequal_sh_9 (float a, float b) +{ + return !((a == b) || __builtin_isunordered (b, a)); +} + +/* { dg-final { scan-tree-dump-times "gimple_simplified to\[^\n\r]*<>" 9 "forwprop1" } } */ diff --git a/gcc/testsuite/gcc.target/i386/opt-comi-1.c b/gcc/testsuite/gcc.target/i386/opt-comi-1.c new file mode 100644 index 00000000000..fc7b8632004 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/opt-comi-1.c @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mfpmath=sse -msse2" } */ +/* { dg-final { scan-assembler-times "comiss" 9 } } */ +/* { dg-final { scan-assembler-times "set" 9 } } */ + +int is_ordered_and_nonequal_sh_1 (float a, float b) +{ + return !__builtin_isunordered (a, b) && (a != b); +} + +int is_ordered_and_nonequal_sh_2 (float a, float b) +{ + return !__builtin_isunordered (a, b) && (b != a); +} + +int is_ordered_and_nonequal_sh_3 (float a, float b) +{ + return (b != a) && !__builtin_isunordered (a, b); +} + +int is_ordered_and_nonequal_sh_4 (float a, float b) +{ + return !__builtin_isunordered (a, b) && !(a == b); +} + +int is_ordered_and_nonequal_sh_5 (float a, float b) +{ + return !__builtin_isunordered (a, b) && !(b == a); +} + +int is_ordered_and_nonequal_sh_6 (float a, float b) +{ + return !(b == a) && !__builtin_isunordered (a, b); +} + +int is_ordered_or_nonequal_sh_7 (float a, float b) +{ + return !(__builtin_isunordered (a, b) || (a == b)); +} + +int is_ordered_or_nonequal_sh_8 (float a, float b) +{ + return !(__builtin_isunordered (a, b) || (b == a)); +} + +int is_ordered_or_nonequal_sh_9 (float a, float b) +{ + return !((a == b) || __builtin_isunordered (b, a)); +} diff --git a/gcc/testsuite/gcc.target/i386/optimize_one.c b/gcc/testsuite/gcc.target/i386/optimize_one.c deleted file mode 100644 index 3a682ed4028..00000000000 --- a/gcc/testsuite/gcc.target/i386/optimize_one.c +++ /dev/null @@ -1,9 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -mfpmath=sse -msse2" } */ -/* { dg-final { scan-assembler-times "comi" 1 } } */ -/* { dg-final { scan-assembler-times "set" 1 } } */ - -int is_ordered_or_nonequal_sh (float a, float b) -{ - return !__builtin_isunordered (a, b) && (a != b); -}