From patchwork Wed Jun 12 03:11:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyu Wang X-Patchwork-Id: 1946624 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=T0Wk1YAM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VzVw11SdBz20KL for ; Wed, 12 Jun 2024 13:12:30 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7F73F385C6C0 for ; Wed, 12 Jun 2024 03:12:28 +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 8181F3858D34 for ; Wed, 12 Jun 2024 03:12:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8181F3858D34 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8181F3858D34 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=1718161930; cv=none; b=F5wi42vzXIwSUbX/7t3fmrJxqRoFzY5ZfCl/MGFXzorPeQdgK8GgYUYJ3GsLyx2gNOGbeUC5RXg1fJ5PNHdLiubymkGo8Kt6aEbHw6xGcP5ZL7a9LrOferqkgQlL9HBVlZs2/YYOslw7R8v6rRG0pBI5IwyBlYyDnl7r5DCvbxg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718161930; c=relaxed/simple; bh=FyEs2sVm7nGoSJFXNtoJBBRoIyD8UeUsvWL5KjQOYnU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=MhXQSaqY7IZY1k0gi5zQPG2ObFtWWNOIEdZ+alIrhN6ZCjUDwkv485/K9I9g/F9lJ7LQsTM/e7nanNoiLtPSsag+K+VlPQnEdnUeqlqBnRm+cbbkFOmDyi7UYrViE/Iv8Vwm+0n9RkX0EmTodqrvHRm+DtWCK1QhA/fyDiQtD9I= 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=1718161928; x=1749697928; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=FyEs2sVm7nGoSJFXNtoJBBRoIyD8UeUsvWL5KjQOYnU=; b=T0Wk1YAMQHjsqKmPi9k0J/2o7bM8jZE94RfT4J0Aukl4aEXNKsCXDxS8 M5X9pM+wIScaPkSgp3RvOUnUhCaW74k5j08MWYSUqKQnMP0ugfVRBW6bW ZA7KgDRmB+3TdsJ/IOee/fX+KyFdtJVgCk1cKJQipdb9pBHhHfhgQ8ygJ 4cRfjJGbx5EuDdZvtJFrwPn6tUcT5m5q3KPrGvBhsk2dxsr398rgXYvB/ s9NVmIKhbF7o/uFkFClxCWyeYBt+8Uer5HCFl7NuCv3cFSdqaxkK7ddCh vVobvdLnlBJvoRUSXkGYEz/P0uh/SfTAMqeW4MxQ/4JgntIirnKOZtALQ w==; X-CSE-ConnectionGUID: jwCbRlICTYa9PDLRdOl1gQ== X-CSE-MsgGUID: Q/Dxi29vR7GrOwPjoWJC1Q== X-IronPort-AV: E=McAfee;i="6600,9927,11100"; a="15130573" X-IronPort-AV: E=Sophos;i="6.08,232,1712646000"; d="scan'208";a="15130573" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2024 20:11:50 -0700 X-CSE-ConnectionGUID: Z0GYqpviTmmviUiwzp9T2g== X-CSE-MsgGUID: I83+rTVOR926POkIDE7j4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,232,1712646000"; d="scan'208";a="40115695" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orviesa006.jf.intel.com with ESMTP; 11 Jun 2024 20:11:49 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 28FCA10081DE; Wed, 12 Jun 2024 11:11:48 +0800 (CST) From: Hongyu Wang To: gcc-patches@gcc.gnu.org Cc: hongtao.liu@intel.com, ubizjak@gmail.com Subject: [PATCH] [APX CCMP] Use ctestcc when comparing to const 0 Date: Wed, 12 Jun 2024 11:11:48 +0800 Message-Id: <20240612031148.114435-1-hongyu.wang@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_NUMSUBJECT, KAM_SHORT, SPF_HELO_NONE, SPF_SOFTFAIL, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, For CTEST, we don't have conditional AND so there's no optimization opportunity to write a new ctest pattern. Emit ctest when ccmp did comparison to const 0 to save bytes. Bootstrapped & regtested under x86-64-pc-linux-gnu. Ok for trunk? gcc/ChangeLog: * config/i386/i386.md (@ccmp): Use ctestcc when operands[3] is const0_rtx. gcc/testsuite/ChangeLog: * gcc.target/i386/apx-ccmp-1.c: Adjust output to scan ctest. * gcc.target/i386/apx-ccmp-2.c: Adjust some condition to compare with 0. --- gcc/config/i386/i386.md | 6 +++++- gcc/testsuite/gcc.target/i386/apx-ccmp-1.c | 10 ++++++---- gcc/testsuite/gcc.target/i386/apx-ccmp-2.c | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index a64f2ad4f5f..014d48cddd6 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -1522,7 +1522,11 @@ (define_insn "@ccmp" [(match_operand:SI 4 "const_0_to_15_operand")] UNSPEC_APX_DFV)))] "TARGET_APX_CCMP" - "ccmp%C1{}\t%G4 {%3, %2|%2, %3}" + { + if (operands[3] == const0_rtx && !MEM_P (operands[2])) + return "ctest%C1{}\t%G4 %2, %2"; + return "ccmp%C1{}\t%G4 {%3, %2|%2, %3}"; + } [(set_attr "type" "icmp") (set_attr "mode" "") (set_attr "length_immediate" "1") diff --git a/gcc/testsuite/gcc.target/i386/apx-ccmp-1.c b/gcc/testsuite/gcc.target/i386/apx-ccmp-1.c index e4e112f07e0..a8b70576760 100644 --- a/gcc/testsuite/gcc.target/i386/apx-ccmp-1.c +++ b/gcc/testsuite/gcc.target/i386/apx-ccmp-1.c @@ -96,9 +96,11 @@ f15 (double a, double b, int c, int d) /* { dg-final { scan-assembler-times "ccmpg" 2 } } */ /* { dg-final { scan-assembler-times "ccmple" 2 } } */ -/* { dg-final { scan-assembler-times "ccmpne" 4 } } */ -/* { dg-final { scan-assembler-times "ccmpe" 3 } } */ +/* { dg-final { scan-assembler-times "ccmpne" 2 } } */ +/* { dg-final { scan-assembler-times "ccmpe" 1 } } */ /* { dg-final { scan-assembler-times "ccmpbe" 1 } } */ +/* { dg-final { scan-assembler-times "ctestne" 2 } } */ +/* { dg-final { scan-assembler-times "cteste" 2 } } */ /* { dg-final { scan-assembler-times "ccmpa" 1 } } */ -/* { dg-final { scan-assembler-times "ccmpbl" 2 } } */ - +/* { dg-final { scan-assembler-times "ccmpbl" 1 } } */ +/* { dg-final { scan-assembler-times "ctestbl" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c b/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c index 0123a686d2c..4a0784394c3 100644 --- a/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c +++ b/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c @@ -12,7 +12,7 @@ int foo_apx(int a, int b, int c, int d) c += d; a += b; sum += a + c; - if (b != d && sum < c || sum > d) + if (b > d && sum != 0 || sum > d) { b += d; sum += b; @@ -32,7 +32,7 @@ int foo_noapx(int a, int b, int c, int d) c += d; a += b; sum += a + c; - if (b != d && sum < c || sum > d) + if (b > d && sum != 0 || sum > d) { b += d; sum += b;