From patchwork Thu Jun 1 16:31:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 1789257 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=GeSF7HZf; dkim-atps=neutral Received: from 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QXBVc0PNmz20QH for ; Fri, 2 Jun 2023 02:32:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0C8B33858421 for ; Thu, 1 Jun 2023 16:32:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C8B33858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685637126; bh=48Lwj7Uxna1X07mijW1XS9PQTklzpipCgwgJaVy60LI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GeSF7HZf5U/+taW3UIrlMn7Rrdse3okjgCzCmvLbo2v4aHFFa/nismhYBIN368a69 8Zj0x+YlN6rbS9AXGoQfGjWcexCp0KEokzcIK/+yNGS5gERhLx7U2O2ok4AneelcQZ NqAc9SOakV3cSiTwbbBTxNtGMea6elQbJp3PieC8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 94EE1385840D for ; Thu, 1 Jun 2023 16:31:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94EE1385840D Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ACE281063 for ; Thu, 1 Jun 2023 09:32:30 -0700 (PDT) Received: from [10.57.74.92] (unknown [10.57.74.92]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D73323F663 for ; Thu, 1 Jun 2023 09:31:44 -0700 (PDT) Message-ID: <21150fd3-ff31-1188-5876-768e7a5edc84@arm.com> Date: Thu, 1 Jun 2023 17:31:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US To: "gcc-patches@gcc.gnu.org" Subject: [PATCH] gimple-range: implement widen plus range X-Spam-Status: No, score=-14.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Andre Vieira \(lists\) via Gcc-patches" From: "Andre Vieira (lists)" Reply-To: "Andre Vieira \(lists\)" Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch adds gimple-range information for the new IFN_VEC_WIDEN_PLUS* internal functions, identical to what VEC_WIDEN_PLUS did. Bootstrapped and regression tested on aarch64-unknown-linux-gnu. gcc/ChangeLog: * gimple-range-op.cc (gimple_range_op_handler::maybe_non_standard): Add support for IFN_VEC_WIDEN_PLUS*. diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index 59c47e2074ddc73065468fe92274c260bd5bac48..7a84931d6204a56549cf1563114d8db7a2e26a6a 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -1187,6 +1187,7 @@ gimple_range_op_handler::maybe_non_standard () { range_operator *signed_op = ptr_op_widen_mult_signed; range_operator *unsigned_op = ptr_op_widen_mult_unsigned; + bool signed1, signed2, signed_ret; if (gimple_code (m_stmt) == GIMPLE_ASSIGN) switch (gimple_assign_rhs_code (m_stmt)) { @@ -1196,32 +1197,58 @@ gimple_range_op_handler::maybe_non_standard () m_op1 = gimple_assign_rhs1 (m_stmt); m_op2 = gimple_assign_rhs2 (m_stmt); tree ret = gimple_assign_lhs (m_stmt); - bool signed1 = TYPE_SIGN (TREE_TYPE (m_op1)) == SIGNED; - bool signed2 = TYPE_SIGN (TREE_TYPE (m_op2)) == SIGNED; - bool signed_ret = TYPE_SIGN (TREE_TYPE (ret)) == SIGNED; - - /* Normally these operands should all have the same sign, but - some passes and violate this by taking mismatched sign args. At - the moment the only one that's possible is mismatch inputs and - unsigned output. Once ranger supports signs for the operands we - can properly fix it, for now only accept the case we can do - correctly. */ - if ((signed1 ^ signed2) && signed_ret) - return; - - m_valid = true; - if (signed2 && !signed1) - std::swap (m_op1, m_op2); - - if (signed1 || signed2) - m_int = signed_op; - else - m_int = unsigned_op; + signed1 = TYPE_SIGN (TREE_TYPE (m_op1)) == SIGNED; + signed2 = TYPE_SIGN (TREE_TYPE (m_op2)) == SIGNED; + signed_ret = TYPE_SIGN (TREE_TYPE (ret)) == SIGNED; break; } default: - break; + return; + } + else if (gimple_code (m_stmt) == GIMPLE_CALL + && gimple_call_internal_p (m_stmt) + && gimple_get_lhs (m_stmt) != NULL_TREE) + switch (gimple_call_internal_fn (m_stmt)) + { + case IFN_VEC_WIDEN_PLUS: + case IFN_VEC_WIDEN_PLUS_LO: + case IFN_VEC_WIDEN_PLUS_HI: + case IFN_VEC_WIDEN_PLUS_EVEN: + case IFN_VEC_WIDEN_PLUS_ODD: + { + signed_op = ptr_op_widen_plus_signed; + unsigned_op = ptr_op_widen_plus_unsigned; + m_valid = false; + m_op1 = gimple_call_arg (m_stmt, 0); + m_op2 = gimple_call_arg (m_stmt, 1); + tree ret = gimple_get_lhs (m_stmt); + signed1 = TYPE_SIGN (TREE_TYPE (m_op1)) == SIGNED; + signed2 = TYPE_SIGN (TREE_TYPE (m_op2)) == SIGNED; + signed_ret = TYPE_SIGN (TREE_TYPE (ret)) == SIGNED; + break; + } + default: + return; } + else + return; + + /* Normally these operands should all have the same sign, but some passes + and violate this by taking mismatched sign args. At the moment the only + one that's possible is mismatch inputs and unsigned output. Once ranger + supports signs for the operands we can properly fix it, for now only + accept the case we can do correctly. */ + if ((signed1 ^ signed2) && signed_ret) + return; + + m_valid = true; + if (signed2 && !signed1) + std::swap (m_op1, m_op2); + + if (signed1 || signed2) + m_int = signed_op; + else + m_int = unsigned_op; } // Set up a gimple_range_op_handler for any built in function which can be