From patchwork Thu Oct 31 06:27:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 99892 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 F37243857704 for ; Thu, 31 Oct 2024 06:32:52 +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 9E5A03857810 for ; Thu, 31 Oct 2024 06:29:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E5A03857810 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 9E5A03857810 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=1730356200; cv=none; b=oJzskgdIq4c7lC5PtYMJLdzCmVGhAnJD2akkRp499Y5J4Zu3xA7owFOfkEuiL0PAGgu4TyONS7b33KXhjtdjlwweiGPkpRUyTLM8nA2U80rm9Ar6q3DEeDlEf3/uSpsJLRqHNjPkFd4zaWOtxoBaIXq8ixjWZwn4DpS1GZqc3Kg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730356200; c=relaxed/simple; bh=8JjeXQ7zD1kqEtuRuZ2yZA1hxj3YyDJX8EnPVCIsnjM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=stczK50JZuaaVxU6PDpm8CxS/YdChPdtbagvUtXDtiV1SrnsM8rYijQP960cqlTJG5LYQiardTCzqkoy0gG1PcsC0SdV4XwUERa90hnMscFW+voC31Tke2KI29UihQ2bNuBJ0knUxrjQ3yJq9LeCbFohTfQfotj8iVYc3uzsUO8= 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=1730356197; x=1761892197; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8JjeXQ7zD1kqEtuRuZ2yZA1hxj3YyDJX8EnPVCIsnjM=; b=UPMxqt96tAfV9AmqmPson/oTZdZY5F5BeKNKSQ6CrZTv7CbVkoT1ALcJ Kjfigw6abpNgS7COxT7NTu2F60c4CYCOvFpxFvwBU2H50x3flCzhjk+lN Y96ANiAa5mO5T1Y7Dnl8Y2ZwnttykaFfe3kxizqm85fOz7plwA6ymPkRy ZXbmHcLcKgroOFkPP91jGOlqDZNWP17T/DPawZ/hIh4wgRSmEbyCpatjr Bo+OuvLv3G8pM6tpXseuM9APeDpjrwI5L+MJ0lBzX2ZyNgL/2krs/gzeK EbXoYmJexWj4WUZIlVA1dTTvLrc581yzTebcO060A5MbbN+ZXm+N/0b86 A==; X-CSE-ConnectionGUID: bsHv0HBJTVOha94sSWS5wQ== X-CSE-MsgGUID: QMxM3USmT6mYHBjd4kn11Q== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30238460" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30238460" 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:29:55 -0700 X-CSE-ConnectionGUID: Uxx2jQc/Qm+9ToBzzdWwEA== X-CSE-MsgGUID: KVM0++AVQTqctDh8F8mb+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,247,1725346800"; d="scan'208";a="82455067" Received: from panli.sh.intel.com ([10.239.154.73]) by orviesa010.jf.intel.com with ESMTP; 30 Oct 2024 23:29:53 -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 08/10] Test: Add testcases for form 6 of unsigned integer SAT_ADD simplify Date: Thu, 31 Oct 2024 14:27:40 +0800 Message-ID: <20241031062742.2709845-8-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 6 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-6-u16.c: New test. * gcc.dg/sat_u_add-simplify-6-u32.c: New test. * gcc.dg/sat_u_add-simplify-6-u64.c: New test. * gcc.dg/sat_u_add-simplify-6-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-6-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u8.c | 11 +++++++++++ 5 files changed, 53 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u8.c diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index 34fae32ae3a..d577adb9a88 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -34,4 +34,13 @@ T sat_u_add_##T##_1 (T x, T y) \ return -1; \ } +#define DEF_SAT_U_ADD_6(T) \ +T sat_u_add_##T##_6 (T x, T y) \ +{ \ + if ((T)(x + y) < x) \ + return -1; \ + else \ + return x + y; \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u16.c new file mode 100644 index 00000000000..83e6a8993b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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_6 (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-6-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u32.c new file mode 100644 index 00000000000..622206486e5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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_6 (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-6-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u64.c new file mode 100644 index 00000000000..f8ea3c8767a --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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_6 (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-6-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-u8.c new file mode 100644 index 00000000000..bcd136d899f --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-6-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_6 (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" } } */