From patchwork Mon Nov 4 10:49:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 2006157 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=GeiFg3go; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4XhpK45Fc5z1xwF for ; Mon, 4 Nov 2024 21:55:19 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B10373857829 for ; Mon, 4 Nov 2024 10:55:17 +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.17]) by sourceware.org (Postfix) with ESMTPS id 6B0703857718 for ; Mon, 4 Nov 2024 10:51:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B0703857718 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 6B0703857718 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730717496; cv=none; b=dXdYjlnDdkjeRwKPpsdo7vzFW3qvQApwwnDHt8j5g+4XGcawDoL8WEKTLvaTlmR7VUO2PB7mX6YuxE+nSI/8a3aIr0ms+AuOILzYAbp5Yo39GZ2S6d2Ky8IoWQQTCHxzlfz4cqfP1Inp6tFXm10gqQGuUhS6WBYE+ulN8wU+C78= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730717496; c=relaxed/simple; bh=TH85cONYiVUQ2S6gsR219XoM0gggldVeIyhKvyhD0OY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=x/e8M10Dm05Kil931nYHrKPDgVjlRI89hg+4/lEOXn/HGM0cnN9S93u57lDEG9fmqMY/+oZGLw2JUxm8YRZCkY3R/2EM9yNoA71Ofbn5152+8dZhGnXm0MoROzQkemg+y5dKvxrygkvdFLuDhQQOHImMLyjCMVsShEODn7IIRPE= 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=1730717486; x=1762253486; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=TH85cONYiVUQ2S6gsR219XoM0gggldVeIyhKvyhD0OY=; b=GeiFg3goQN20D44XGJPDnTwydLFgrhmdV9HrMLiASO1tTjFhvninZ09l qihMUxxoWGDamQ2nsT3lMkPTDoEsYJUZxav0qIwjbpiMo6UVfXENcvtu8 xmD8NMEU77VrrWZPF5I9eFIxK8/NZtISM0xPEXYQE8iVD1Nl86LXfHziU uzus0ZdpnXNZkZaK/B9EKTEmSnJZ3aiQmoNcxE+ei+GVcsNMKaiJgx4GL tkPU97uV9RuUDuyEDilekQhstpXa2FQ6IOz7qXGoOY6lJ2NjkQmHqJq0K i3oLeQqG9GTfy7s/VuIafNu9SoKbeGLQU/62CIj0P9q1gie/QNreo4ftJ A==; X-CSE-ConnectionGUID: O//1VEK3SHCPURjrVymUhQ== X-CSE-MsgGUID: qh1B8NqLQXOpgVeW/gDQyA== X-IronPort-AV: E=McAfee;i="6700,10204,11245"; a="30510247" X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="30510247" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 02:51:25 -0800 X-CSE-ConnectionGUID: 3mUXqKolRtymhK42l+0QTQ== X-CSE-MsgGUID: c6g8aQZ4QVGTTjzdgYg3/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="83732548" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa008.fm.intel.com with ESMTP; 04 Nov 2024 02:51:22 -0800 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 v1 1/5] Match: Simplify branch form 5 of unsigned SAT_ADD into branchless Date: Mon, 4 Nov 2024 18:49:20 +0800 Message-ID: <20241104104924.1743778-1-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 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 From: Pan Li There are sorts of forms for the unsigned SAT_ADD. Some of them are complicated while others are cheap. This patch would like to simplify the complicated form into the cheap ones. For example as below: From the form 4 (branch): SUM = ADD_OVERFLOW (X, Y) SAT_U_ADD = IMAGPART_EXPR (SUM) == 0 ? REALPART_EXPR (SUM) : -1 To (branchless): SAT_U_ADD = (X + Y) | - ((X + Y) < X). #define T uint8_t T sat_add_u_1 (T x, T y) { T ret; return __builtin_add_overflow (x, y, &ret) == 0 ? ret : - 1; } Before this patch in phiopt2: 4 │ uint8_t sat_u_add_uint8_t_9 (uint8_t x, uint8_t y) 5 │ { 6 │ unsigned char _1; 7 │ unsigned char _2; 8 │ uint8_t _3; 9 │ __complex__ unsigned char _6; 10 │ 11 │ [local count: 1073741824]: 12 │ _6 = .ADD_OVERFLOW (x_4(D), y_5(D)); 13 │ _1 = REALPART_EXPR <_6>; 14 │ _2 = IMAGPART_EXPR <_6>; 15 │ if (_2 != 0) 16 │ goto ; [35.00%] 17 │ else 18 │ goto ; [65.00%] 19 │ 20 │ [local count: 375809640]: 21 │ 22 │ [local count: 1073741824]: 23 │ # _3 = PHI <255(3), _1(2)> 24 │ return _3; 25 │ 26 │ } After this patch 14 │ uint8_t sat_u_add_uint8_t_9 (uint8_t x, uint8_t y) 15 │ { 16 │ unsigned char _1; 17 │ __complex__ unsigned char _6; 18 │ unsigned char _8; 19 │ _Bool _9; 20 │ unsigned char _10; 21 │ unsigned char _11; 22 │ unsigned char _12; 23 │ 24 │ [local count: 1073741824]: 25 │ _6 = .ADD_OVERFLOW (x_4(D), y_5(D)); // Dead code 26 │ _1 = REALPART_EXPR <_6>; // Ditto 27 │ _8 = x_4(D) + y_5(D); 28 │ _9 = x_4(D) > _8; 29 │ _10 = (unsigned char) _9; 30 │ _11 = -_10; 31 │ _12 = _8 | _11; 32 │ return _12; 33 │ 34 │ } This patch also add 2 more imm matching for unsigned SAT_ADD due to remove the add_overflow match. The below test suites are passed for this patch. * The rv64gcv fully regression test. * The x86 bootstrap test. * The x86 fully regression test. gcc/ChangeLog: * match.pd: Remove unsigned branch form 4 and simplify to the branchless of unsigned SAT_ADD, add 2 new form for imm. Signed-off-by: Pan Li --- gcc/match.pd | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index f6f55491b89..8ed08b95bc0 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3160,14 +3160,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* From SAT_U_ADD = (X + Y) < x ? -1 : (X + Y). */ (simplify (cond (lt (plus:c@2 @0 @1) @0) integer_minus_onep @2) (if (types_match (type, @0, @1)) - (bit_ior (plus@2 @0 @1) (negate (convert (lt @2 @0))))))) - -/* Unsigned saturation add, case 5 (branch with eq .ADD_OVERFLOW): - SUM = ADD_OVERFLOW (X, Y) - SAT_U_ADD = IMAGPART_EXPR (SUM) == 0 ? REALPART_EXPR (SUM) : -1. */ -(match (unsigned_integer_sat_add @0 @1) - (cond^ (eq (imagpart (IFN_ADD_OVERFLOW:c @0 @1)) integer_zerop) - (usadd_left_part_2 @0 @1) integer_minus_onep)) + (bit_ior (plus@2 @0 @1) (negate (convert (lt @2 @0)))))) + /* From SUM = ADD_OVERFLOW (X, Y) + SAT_U_ADD = IMAGPART_EXPR (SUM) == 0 ? REALPART_EXPR (SUM) : -1 */ + (simplify (cond (eq (imagpart (IFN_ADD_OVERFLOW:c@2 @0 @1)) integer_zerop) + (realpart @2) integer_minus_onep) + (if (types_match (type, @0, @1)) + (bit_ior (plus@3 @0 @1) (negate (convert (lt @3 @0))))))) /* Unsigned saturation add, case 6 (branch with ne .ADD_OVERFLOW): SUM = ADD_OVERFLOW (X, Y) @@ -3201,6 +3200,36 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && types_match (type, @0) && int_fits_type_p (@1, type)))) +/* Unsigned saturation add, case 11 (one op is imm): + SAT_U_ADD = (X + 3) | -(X > (umax - 3)). */ +(match (unsigned_integer_sat_add @0 @1) + (bit_ior:c (plus:c @0 INTEGER_CST@1) (negate (convert (gt @0 INTEGER_CST@2)))) + (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) + && types_match (type, @0, @1)) + (with + { + unsigned precision = TYPE_PRECISION (type); + wide_int cst_1 = wi::to_wide (@1); + wide_int cst_2 = wi::to_wide (@2); + wide_int max = wi::mask (precision, false, precision); + wide_int sum = wi::add (cst_1, cst_2); + } + (if (wi::eq_p (max, sum)))))) + +/* Unsigned saturation add, case 12 (one op is imm). Almost the same form + as the case 11 but the gimple changes when INTEGER_CST@1 is umax. */ +(match (unsigned_integer_sat_add @0 @1) + (bit_ior:c (plus:c @0 INTEGER_CST@1) (negate (convert (ne @0 integer_zerop)))) + (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) + && types_match (type, @0, @1)) + (with + { + unsigned precision = TYPE_PRECISION (type); + wide_int cst_1 = wi::to_wide (@1); + wide_int max = wi::mask (precision, false, precision); + } + (if (wi::eq_p (max, cst_1)))))) + /* Signed saturation add, case 1: T sum = (T)((UT)X + (UT)Y) SAT_S_ADD = (X ^ sum) & !(X ^ Y) < 0 ? (-(T)(X < 0) ^ MAX) : sum; From patchwork Mon Nov 4 10:49:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 2006153 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=IC5mvuVA; 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 4XhpHq186Yz1xxN for ; Mon, 4 Nov 2024 21:54:15 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 54B413857BAF for ; Mon, 4 Nov 2024 10:54:13 +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.17]) by sourceware.org (Postfix) with ESMTPS id 742903857B96 for ; Mon, 4 Nov 2024 10:51:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 742903857B96 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 742903857B96 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730717495; cv=none; b=HwzTEdVtpQzMQUQZzGbguoy9GbFe/EtmZOnBzINQhLMeLH7E4trVc0GJxW+r5Fl53arJom/alrhZWzU8cHx1AkA6nUIZvkYax+W9cQZ5bNmZPDLmR1VwOYyRWNGuPvhcPlRks27Gz6SkUfaYmAEAhDSKAtIVBSxXG3CFxo+uHGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730717495; c=relaxed/simple; bh=mxKK4XI//ORWjTB7VNoazzASF37QFtV2B9fR/sey8MU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Hp7KhtWchDKRGSNoqjqrB7Nkx7S6TQnJn3SvDsoHkEHRZBYGukvWZOiDlJHOJTPQ1sDj5jK4qQu8tQ5+IJopx0Xx2IHE5h5BBskVH8GGt+9Uup2kWfynek+13Y/9a06ihGi0rge/iStH9g4De82XJoSwBdNgZVMFKzslFVZQHx0= 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=1730717488; x=1762253488; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mxKK4XI//ORWjTB7VNoazzASF37QFtV2B9fR/sey8MU=; b=IC5mvuVA7Be0u7DlitHbNTOsq1cLd3fA7U/fbQpFSPvBQ9aa9gRE0nRD fjIk/VHY8XjFyS+vbobgzM8jyOyuN4D/0VEsjqc5eofE9+itHoDinYXJz I6OKrnRPNtmmsovW8gyF5jVNKZNJaKOlSfFOKaj48qnHriWcOd0Pj4TGT AA74hjucvDXUUrTKaXKIcUf1WHPCazLa/cZJVLeMBxgK00WossSmOi6Io 2RrK04SPd5mLzoMRHhDzj//eC+DHRW9zeub+ifo5cPiCSz+kU5l24yfYC v5pBmqjV6bFyyfyRaJBaw4SIl3N411bV3lpjQfL2ahrB99l+wiU//TYZP g==; X-CSE-ConnectionGUID: Ym44PD7cQhypfxH6CsuZng== X-CSE-MsgGUID: ib1Jg2LOThuwZ3G2ICZG3g== X-IronPort-AV: E=McAfee;i="6700,10204,11245"; a="30510250" X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="30510250" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 02:51:27 -0800 X-CSE-ConnectionGUID: CAVqBpB+QZeTYMo/SzOhpA== X-CSE-MsgGUID: f/xcmSI9RrOYDn0aXPSqWQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="83732561" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa008.fm.intel.com with ESMTP; 04 Nov 2024 02:51:24 -0800 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 v1 2/5] Test: Add testcases for form 9 of unsigned integer SAT_ADD simplify Date: Mon, 4 Nov 2024 18:49:21 +0800 Message-ID: <20241104104924.1743778-2-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241104104924.1743778-1-pan2.li@intel.com> References: <20241104104924.1743778-1-pan2.li@intel.com> MIME-Version: 1.0 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 From: Pan Li The phiopt2 pass will also try the gimple_simplify for the form 9 of unsigned integer SAT_ADD. Thus add the testcase to make sure it will be performed in phiopt2 pass. The below test suites are passed for this patch: 1. The rv64gcv fully regression tests. 2. The x86 bootstrap tests. 3. The x86 fully regression tests. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test helper macros. * gcc.dg/sat_u_add-simplify-9-u16.c: New test. * gcc.dg/sat_u_add-simplify-9-u32.c: New test. * gcc.dg/sat_u_add-simplify-9-u64.c: New test. * gcc.dg/sat_u_add-simplify-9-u8.c: New test. Signed-off-by: Pan Li --- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 7 +++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c | 11 +++++++++++ 5 files changed, 51 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index 3d4ec184452..91691c167a0 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -61,4 +61,11 @@ T sat_u_add_##T##_8 (T x, T y) \ return x + y; \ } +#define DEF_SAT_U_ADD_9(T) \ +T sat_u_add_##T##_9 (T x, T y) \ +{ \ + T ret; \ + return __builtin_add_overflow (x, y, &ret) == 0 ? ret : - 1; \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u16.c new file mode 100644 index 00000000000..9e93dde6e3f --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-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_9 (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-9-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u32.c new file mode 100644 index 00000000000..4dc760ac78c --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-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_9 (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-9-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u64.c new file mode 100644 index 00000000000..8748e03e1f5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-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_9 (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-9-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-u8.c new file mode 100644 index 00000000000..5cffc43e081 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-9-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_9 (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" } } */ From patchwork Mon Nov 4 10:49:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 2006154 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=Ji7qfhBn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4XhpHq5Zxfz1xyH for ; Mon, 4 Nov 2024 21:54:15 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AED243857823 for ; Mon, 4 Nov 2024 10:54:13 +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.17]) by sourceware.org (Postfix) with ESMTPS id B5B49385783B for ; Mon, 4 Nov 2024 10:51:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B5B49385783B 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 B5B49385783B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730717500; cv=none; b=Hw1F0+7YuqkrbqhAvV+civ7HfyvQbnf7Nn6AVYCL5oPs0uAQSawLkzyUjxDlbY1HZEePhmcSHu+D48OgRFGDTeyVgjnwNNCXTVLnqtRQH7aZJLjgT0Q0P+jrF3EJGhEvFFOUQpKKaGRMA7xPDXprKDdlBbQTEXsP+ZHAruHyQZ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730717500; c=relaxed/simple; bh=RekNkA79CrEycoKdBqWapEUj/Lj8Fe7nYca72X1ed34=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=F9ddK6FFnI43O5XOuzElq3aIrTwpsEr/54xf8xxDB5KO1hYysgMT2jGBVnuFPqTVarAfydAPOUx8Eu2lWIhBPn8T4dewoDV0XgI34ioI2brsH+NDpuLiP0NLwWYKXH5l9q+JMoTIHpOtN9Txw7F1/UHCdqUTT4wm4izl0mzE86g= 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=1730717490; x=1762253490; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RekNkA79CrEycoKdBqWapEUj/Lj8Fe7nYca72X1ed34=; b=Ji7qfhBnJDddiT7so356Wh9KhrkK1wZ8hKMt4ZKd8we1snRIvY7MBNd+ Xj05edAs+gdoVSSxoYmMfyvJxZzia+jcTLAcLjGnb2bqBDHt3HD726Pqy rHbpi6PnUFiGD4bPU39wogx6LCTC1CoUuHIklxqjvJ0haUzSKVtRM8rWq le4vuxpJygJdnXrrRk3IZ93xmJ977jpEEEbyPOm3ncef79ZRWceXFq7CA EPpgwfMNsaNemTk9/TS6Yt0FwbU6qs5GQgdRgIby46PTR1DdN5JBmLp7N rZ2tJUcLCkmD/jxINoT5NCgs2PZ2KEeqQXEP+94X/Ornz0S7qiF2RbhVI w==; X-CSE-ConnectionGUID: wdFnlZE3QYWJOtdojVco6Q== X-CSE-MsgGUID: tAAXtUZ+QayEDna18cqxDQ== X-IronPort-AV: E=McAfee;i="6700,10204,11245"; a="30510255" X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="30510255" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 02:51:29 -0800 X-CSE-ConnectionGUID: liKEHGa/TnCQhrJwMBBaKw== X-CSE-MsgGUID: +25SoDohQSmmwOmylPrlaw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="83732574" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa008.fm.intel.com with ESMTP; 04 Nov 2024 02:51:27 -0800 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 v1 3/5] Test: Add testcases for form 10 of unsigned integer SAT_ADD simplify Date: Mon, 4 Nov 2024 18:49:22 +0800 Message-ID: <20241104104924.1743778-3-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241104104924.1743778-1-pan2.li@intel.com> References: <20241104104924.1743778-1-pan2.li@intel.com> MIME-Version: 1.0 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 From: Pan Li The phiopt2 pass will also try the gimple_simplify for the form 10 of unsigned integer SAT_ADD. Thus add the testcase to make sure it will be performed in phiopt2 pass. The below test suites are passed for this patch: 1. The rv64gcv fully regression tests. 2. The x86 bootstrap tests. 3. The x86 fully regression tests. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test helper macros. * gcc.dg/sat_u_add-simplify-10-u16.c: New test. * gcc.dg/sat_u_add-simplify-10-u32.c: New test. * gcc.dg/sat_u_add-simplify-10-u64.c: New test. * gcc.dg/sat_u_add-simplify-10-u8.c: New test. Signed-off-by: Pan Li --- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 7 +++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u8.c | 11 +++++++++++ 5 files changed, 51 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u8.c diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index 91691c167a0..5d7644c826e 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -68,4 +68,11 @@ T sat_u_add_##T##_9 (T x, T y) \ return __builtin_add_overflow (x, y, &ret) == 0 ? ret : - 1; \ } +#define DEF_SAT_U_ADD_10(T) \ +T sat_u_add_##T##_10 (T x, T y) \ +{ \ + T ret; \ + return !__builtin_add_overflow (x, y, &ret) ? ret : - 1; \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u16.c new file mode 100644 index 00000000000..614dc59b9e9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-10-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_10 (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-10-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u32.c new file mode 100644 index 00000000000..bc4f3ba2b1a --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-10-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_10 (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-10-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u64.c new file mode 100644 index 00000000000..b220e045f15 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-10-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_10 (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-10-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-10-u8.c new file mode 100644 index 00000000000..3404d4155c5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-10-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_10 (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" } } */ From patchwork Mon Nov 4 10:49:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 2006148 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=Y3vV/DEL; 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 4XhpGd5n7Tz1xxN for ; Mon, 4 Nov 2024 21:53:13 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0ADCD3857BAF for ; Mon, 4 Nov 2024 10:53:12 +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.17]) by sourceware.org (Postfix) with ESMTPS id A63B03858D29 for ; Mon, 4 Nov 2024 10:51:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A63B03858D29 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 A63B03858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730717500; cv=none; b=tTvBr3vznzFce7778ye4aoPRux6/OKTY/j4YZshmyqxnsIvRBH1oQhN6MGaA5nVHegeUtNCKbY6SDLDGZDN0rNYrnEBuRlyuemG809g6/G6nNW7YGY0D35MKy0Dbe0Ma5TwDcIsyRU9KDpfJ7ZMPTuiThYb/6DiKSVrHyvoLpKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730717500; c=relaxed/simple; bh=X5Wv+bPsnhl/LJlOjqsmGcE10iNmszANjHhRGIo0pZk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Qb85NbetI6TwSkarBirdAiPHQqtxV2Ovw91BCqXipF+4pTdnYjx3VPVD0cjy6r5s3n3iE+IRfJ6TrwGjM8TlTwOdmT3NUNDcl9v+0E27dTaRdo2oB5loT4OMwZQ/4N8TOSabG0CzEwxHKthjADjhETbB9hBDLe04QzAf0ocWAFM= 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=1730717497; x=1762253497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X5Wv+bPsnhl/LJlOjqsmGcE10iNmszANjHhRGIo0pZk=; b=Y3vV/DELXf4jVBFuSMtWhRKXb+UCNmXOT8uvJz0YL4q4nDajUDLzW1mK P60ewhiCHvCVMnY4NtDXAkV0AYVbYA1ZdqvOsaZ/FRtp4wjgmERDEoHPm qCjrrNK/O+GQnChfVfTMdMa2C0SnJjzclTAsVinxm04uSqcdM1snKWieX gpsJSPHlXKXpImjOGaOPuZFboFtmvVAVhSHWpFaVePhuqdrlZEDj0jwdg DHEOT5t9IFiy240ap5CMrTdYTQIL7b7kFTxv8WfOQA4W2P+H2yo4UB7gg d1fQOVcqS1Bba0LRxqCBvrGiM8WApbGiqQTgs5TM1yejRfzewRTS3qlOo g==; X-CSE-ConnectionGUID: AxVvb6GbT4eEXKKFook3CA== X-CSE-MsgGUID: kgqJxbNgR3m5CCtFr+5xoQ== X-IronPort-AV: E=McAfee;i="6700,10204,11245"; a="30510261" X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="30510261" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 02:51:31 -0800 X-CSE-ConnectionGUID: 4ysx5uLzQiCzeu/SxTcrBg== X-CSE-MsgGUID: rTGJrxn8T2ehMEYks9asrw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="83732591" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa008.fm.intel.com with ESMTP; 04 Nov 2024 02:51:29 -0800 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 v1 4/5] Test: Add testcases for form 11 of unsigned integer SAT_ADD simplify Date: Mon, 4 Nov 2024 18:49:23 +0800 Message-ID: <20241104104924.1743778-4-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241104104924.1743778-1-pan2.li@intel.com> References: <20241104104924.1743778-1-pan2.li@intel.com> MIME-Version: 1.0 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 From: Pan Li The phiopt2 pass will also try the gimple_simplify for the form 11 of unsigned integer SAT_ADD. Thus add the testcase to make sure it will be performed in phiopt2 pass. The below test suites are passed for this patch: 1. The rv64gcv fully regression tests. 2. The x86 bootstrap tests. 3. The x86 fully regression tests. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test helper macros. * gcc.dg/sat_u_add-simplify-11-u16.c: New test. * gcc.dg/sat_u_add-simplify-11-u32.c: New test. * gcc.dg/sat_u_add-simplify-11-u64.c: New test. * gcc.dg/sat_u_add-simplify-11-u8.c: New test. Signed-off-by: Pan Li --- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 10 ++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u8.c | 11 +++++++++++ 5 files changed, 54 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u8.c diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index 5d7644c826e..7cf183723ec 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -75,4 +75,14 @@ T sat_u_add_##T##_10 (T x, T y) \ return !__builtin_add_overflow (x, y, &ret) ? ret : - 1; \ } +#define DEF_SAT_U_ADD_11(T) \ +T sat_u_add_##T##_11 (T x, T y) \ +{ \ + T ret; \ + if (__builtin_add_overflow (x, y, &ret) == 0) \ + return ret; \ + else \ + return -1; \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u16.c new file mode 100644 index 00000000000..73831d42cd6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-11-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_11 (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-11-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u32.c new file mode 100644 index 00000000000..3011d6eb341 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-11-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_11 (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-11-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u64.c new file mode 100644 index 00000000000..0d93b089b35 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-11-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_11 (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-11-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-11-u8.c new file mode 100644 index 00000000000..d67d5cb17a9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-11-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_11 (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" } } */ From patchwork Mon Nov 4 10:49:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2" X-Patchwork-Id: 2006147 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=aHKraTxk; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4XhpGZ2XC0z1xxN for ; Mon, 4 Nov 2024 21:53:10 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8FA5C385780F for ; Mon, 4 Nov 2024 10:53:08 +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.17]) by sourceware.org (Postfix) with ESMTPS id AA10F3858280 for ; Mon, 4 Nov 2024 10:51:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA10F3858280 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 AA10F3858280 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730717500; cv=none; b=FgNT1IgtDBFyK3HgY7C/mmHwpir65x4BrwX3PXAFmhpzXR29jRDm2S/ahkNdc1HOwq8U5nAzCMWHIoGLgGPQLPDvXNQcWL+VBu3CW76v9d9++9hVcwk42rgaBw/6+6m9GUY6GS4r9t7fuGHSe2tlACH+iSLt5yNAVSywDEioGXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730717500; c=relaxed/simple; bh=OI4bfC/yGZK5ME2lik6Gwa6EogvifEeArRbuCLfygK4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=bTS1Ge6mwL/fWjLRKoeQW7WKtSwNNo6RtZ/ud3SLuI1NDbR1dzKEnaiNm/bV+ohcXhNgPwN9k0JMwFNKWBVFIbF+7qQwMo+2I4n8icxvhhfrcDKBzZ4+V7zhhYUBbC8DX8B1iS0qCsdVwck2xzUDaWCuua++do6LwPnK14tanG4= 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=1730717497; x=1762253497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OI4bfC/yGZK5ME2lik6Gwa6EogvifEeArRbuCLfygK4=; b=aHKraTxkGv6v7mF+bdkBS1IrgOcGS119rxLZgcycfR0R/cGcKy+TwpFN C4YAnUmHgTNrwejbKl4+dTTztXIkDp1Crmf4W54UPcqfXrufEw/jwa4yu uXyCwKUfwl090ZzkrbF9NdG5N3vru874yxnD902UN+zTW8aN8m0JKb6DW dBjYJSKi/yAb4yu5xzmPRXq1FjrvRApH/iSK3h6A0PeavKH+RBLnyExD+ vWnFqDpnhVWlLIehhzW9jT7ankSFRQVZT3N4gdrOaXmrxU9+iXsulTBMC wbl+BIkAyaKBqu4BGx0X3NQnw1QrX+ZR3O+2wDLL/GeZj9xqwOaHC5FyS w==; X-CSE-ConnectionGUID: TqNe7xhVRvuNUyFkLG/T0A== X-CSE-MsgGUID: DEEpgECHRvSm/ohMwHljog== X-IronPort-AV: E=McAfee;i="6700,10204,11245"; a="30510267" X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="30510267" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 02:51:34 -0800 X-CSE-ConnectionGUID: fzDjk5ztSaKC0Dr1X5BcTQ== X-CSE-MsgGUID: aq+Z8Fo6TW6bATKtL512XA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="83732600" Received: from panli.sh.intel.com ([10.239.154.73]) by fmviesa008.fm.intel.com with ESMTP; 04 Nov 2024 02:51:31 -0800 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 v1 5/5] Test: Add testcases for form 12 of unsigned integer SAT_ADD simplify Date: Mon, 4 Nov 2024 18:49:24 +0800 Message-ID: <20241104104924.1743778-5-pan2.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241104104924.1743778-1-pan2.li@intel.com> References: <20241104104924.1743778-1-pan2.li@intel.com> MIME-Version: 1.0 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 From: Pan Li The phiopt2 pass will also try the gimple_simplify for the form 12 of unsigned integer SAT_ADD. Thus add the testcase to make sure it will be performed in phiopt2 pass. The below test suites are passed for this patch: 1. The rv64gcv fully regression tests. 2. The x86 bootstrap tests. 3. The x86 fully regression tests. gcc/testsuite/ChangeLog: * gcc.dg/sat_arith_simplify.h: Add test helper macros. * gcc.dg/sat_u_add-simplify-12-u16.c: New test. * gcc.dg/sat_u_add-simplify-12-u32.c: New test. * gcc.dg/sat_u_add-simplify-12-u64.c: New test. * gcc.dg/sat_u_add-simplify-12-u8.c: New test. Signed-off-by: Pan Li --- gcc/testsuite/gcc.dg/sat_arith_simplify.h | 10 ++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u16.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u64.c | 11 +++++++++++ gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u8.c | 11 +++++++++++ 5 files changed, 54 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u16.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u32.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u64.c create mode 100644 gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u8.c diff --git a/gcc/testsuite/gcc.dg/sat_arith_simplify.h b/gcc/testsuite/gcc.dg/sat_arith_simplify.h index 7cf183723ec..c21c8dcaa66 100644 --- a/gcc/testsuite/gcc.dg/sat_arith_simplify.h +++ b/gcc/testsuite/gcc.dg/sat_arith_simplify.h @@ -85,4 +85,14 @@ T sat_u_add_##T##_11 (T x, T y) \ return -1; \ } +#define DEF_SAT_U_ADD_12(T) \ +T sat_u_add_##T##_12 (T x, T y) \ +{ \ + T ret; \ + if (!__builtin_add_overflow (x, y, &ret)) \ + return ret; \ + else \ + return -1; \ +} + #endif diff --git a/gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u16.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u16.c new file mode 100644 index 00000000000..7b8cb87aa8b --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-12-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_12 (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-12-u32.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u32.c new file mode 100644 index 00000000000..a39ae54fe0a --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-12-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_12 (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-12-u64.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u64.c new file mode 100644 index 00000000000..ad8da11b27a --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-12-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_12 (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-12-u8.c b/gcc/testsuite/gcc.dg/sat_u_add-simplify-12-u8.c new file mode 100644 index 00000000000..b64fad38d7f --- /dev/null +++ b/gcc/testsuite/gcc.dg/sat_u_add-simplify-12-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_12 (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" } } */