From patchwork Thu Oct 31 06:27:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 99893 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 C05C13857706 for ; Thu, 31 Oct 2024 06:33:01 +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 [198.175.65.16]) by sourceware.org (Postfix) with ESMTPS id 9945F385771E for ; Thu, 31 Oct 2024 06:30:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9945F385771E 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 9945F385771E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356203; cv=none; b=DQg0NOEP2AD2y+lHxkA72P0E2enITL9VeBdTg1DXfpDX2kFNYIeh/lLGhZiFAPhvsxYLgSOCDZtAJwwweUq4jA27O/LjK8dWz5FNL7OHdIx5F8s4YgTML0xbZP3uCdKpap1iAl46F1FRiFrEX3VlJD63uIAPsr/ekmZFOsPi3+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356203; c=relaxed/simple; bh=ubNL9qYupcoQp8C5V98RI5vVHgkreDcmjsvPrzT/4IE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=e9fX4xWGM2Hns9++6hxQNeASXjH/5/XFhCQwa1nl6KmCgssGh8Zy12pncWTN6wpDOS7RoNBOh5GP2LHv+/4Tj4bQWvPGtWVRNoGi0xalcXCOnRHzmp7JWiug8leLPKs4PLUcM7ND6GmFEJQmYZI7g9i0bECEbUemDuU2l5myWsE= 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=1730356201; x=1761892201; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ubNL9qYupcoQp8C5V98RI5vVHgkreDcmjsvPrzT/4IE=; b=QyYKKvQF5VfhUrpxfukss4EBep7VY67uiDXt8TWp9Sy703d/l8gpTRMN qm53BAZQkLLNCjtuky2u1ICJZCCIQYJhIi/sw3H41zBFkrG9HUd0pyvaf 6SUJNviFYUjLOck0fVtS6BFN3GWsFIsfUAYX4IOxGy0Hd2qQulmGlewUz RfJ3rUYCbVu9pCf2rGPMVx8diYIaktUfgdiVCzZHesDVpNuSJknN9gc3B S41RVG4KESqaLw/NPPXaZ3Dxe+cDcOy6G6Q26oV+1z/5qEHF720G9cY7F WDMiFGoafGZ8lqLGpd9BPaYPQj0bqeyS87FSLvpgYu3x1iaNHCiBrOu3E g==; X-CSE-ConnectionGUID: k45FotWzR/WTLDTBTPwcLg== X-CSE-MsgGUID: JChioIBdSH+kLPFwVIzsrg== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30238474" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30238474" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2024 23:30:00 -0700 X-CSE-ConnectionGUID: r7FlCUxbSmK7j1cIHdM6Dg== X-CSE-MsgGUID: 9PMzizH2RZOCknBNRZd1gw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82455078" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa010.jf.intel.com with ESMTP; 30 Oct 2024 23:29:58 -0700 From: pan2.li@intel.com To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com, Tamar.Christina@arm.com, juzhe.zhong@rivai.ai, kito.cheng@gmail.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Pan Li Subject: [PATCH v2 10/10] Test: Add testcases for form 8 of unsigned integer SAT_ADD simplify Date: Thu, 31 Oct 2024 14:27:42 +0800 Message-ID: <20241031062742.2709845-10-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241031062742.2709845-1-pan2.li@intel.com> References: <20241031062742.2709845-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP 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 From: Pan Li The phiopt2 pass will also try the gimple_simplify for the form 8 of unsigned integer SAT_ADD. Thus add the testcase to make sure it will be performed in phiopt2 pass. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test helper macros. * gcc.dg/sat_u_add-simplify-8-u16.c: New test. * gcc.dg/sat_u_add-simplify-8-u32.c: New test. * gcc.dg/sat_u_add-simplify-8-u64.c: New test. * gcc.dg/sat_u_add-simplify-8-u8.c: New test. Signed-off-by: Pan Li --- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 9 +++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u8.c | 11 +++++++++++ 5 files changed, 53 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u8.c diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index a9d183c9abf..3d4ec184452 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -52,4 +52,13 @@ T sat_u_add_##T##_7 (T x, T y) \ return -1; \ } +#define DEF_SAT_U_ADD_8(T) \ +T sat_u_add_##T##_8 (T x, T y) \ +{ \ + if (x > (T)(x + y)) \ + return -1; \ + else \ + return x + y; \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u16.c new file mode 100644 index 00000000000..1a38931fd74 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u16.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_8 (uint16_t) + +/* { dg-final { scan-tree-dump-not " if " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " else " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " goto " "phiopt2" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u32.c new file mode 100644 index 00000000000..b333ce5e407 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u32.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_8 (uint32_t) + +/* { dg-final { scan-tree-dump-not " if " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " else " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " goto " "phiopt2" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u64.c new file mode 100644 index 00000000000..2f0e18e4a17 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u64.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_8 (uint64_t) + +/* { dg-final { scan-tree-dump-not " if " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " else " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " goto " "phiopt2" } } */ diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u8.c new file mode 100644 index 00000000000..97878e127f3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-8-u8.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-phiopt2-details" } */ + +#include +#include "sat_arith_simplify.h" + +DEF_SAT_U_ADD_8 (uint8_t) + +/* { dg-final { scan-tree-dump-not " if " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " else " "phiopt2" } } */ +/* { dg-final { scan-tree-dump-not " goto " "phiopt2" } } */