From patchwork Wed Jun 7 14:20:41 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: 1791733 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=8.43.85.97; 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=XWznHRLD; dkim-atps=neutral Received: from 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QbqJp5VR4z20Q8 for ; Thu, 8 Jun 2023 00:21:14 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C44263857724 for ; Wed, 7 Jun 2023 14:21:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C44263857724 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686147671; bh=CGT5czxAXwrg1GzWD4ZiEecebVuZMfoRLBHQwz/Eu+Q=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=XWznHRLDWyP+4c30FZ4taiu2nXOaczsFKfwEf/uiD3ahkffHcHiR1tE3Ou9q5qqsh dmAIZp/EYwjLyMPTmubG2ddxEQRpF4c2C3S8h7VRAcGiMW1ZXxE1hVEyZFLc2H9Npa BG/7oZQ4TvxBHq9z/C/nXMXUk67DjsHx+Aririzg= 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 4A5C33858C54 for ; Wed, 7 Jun 2023 14:20:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A5C33858C54 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 55EBCAB6; Wed, 7 Jun 2023 07:21:33 -0700 (PDT) Received: from [10.57.74.33] (unknown [10.57.74.33]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 45BE63F587; Wed, 7 Jun 2023 07:20:47 -0700 (PDT) Message-ID: Date: Wed, 7 Jun 2023 15:20:41 +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 Cc: Richard Biener , Richard Sandiford Subject: vect: Don't pass subtype to vect_widened_op_tree where not needed [PR 110142] X-Spam-Status: No, score=-14.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_LOTSOFHASH, 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 fixes an issue introduced by g:2f482a07365d9f4a94a56edd13b7f01b8f78b5a0, where a subtype was beeing passed to vect_widened_op_tree, when no subtype was to be used. This lead to an errorneous use of IFN_VEC_WIDEN_MINUS. gcc/ChangeLog: * tree-vect-patterns.cc (vect_recog_widen_op_pattern): Don't pass subtype to vect_widened_op_tree and remove subtype parameter. (vect_recog_widen_plus_pattern): Remove subtype parameter and dont pass to call to vect_recog_widen_op_pattern. (vect_recog_widen_minus_pattern): Likewise. gcc/testsuite/ChangeLog: * gcc.dg/vect/pr110142.c: New test. diff --git a/gcc/testsuite/gcc.dg/vect/pr110142.c b/gcc/testsuite/gcc.dg/vect/pr110142.c new file mode 100644 index 0000000000000000000000000000000000000000..a88dbe400f46a33a53649298345c24c569e2f567 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr110142.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +void test(short *x, unsigned short *y, int n) +{ + for (int i = 0; i < n; i++) + x[i] = (y[i] - x[i]) >> 1; +} + +/* { dg-final { scan-tree-dump-not "widen_minus" "vect" } } */ diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index dc102c919352a0328cf86eabceb3a38c41a7e4fd..599a027f9b2feb8971c1ee017b6457bc297c86c2 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -1405,15 +1405,14 @@ static gimple * vect_recog_widen_op_pattern (vec_info *vinfo, stmt_vec_info last_stmt_info, tree *type_out, tree_code orig_code, code_helper wide_code, - bool shift_p, const char *name, - optab_subtype *subtype = NULL) + bool shift_p, const char *name) { gimple *last_stmt = last_stmt_info->stmt; vect_unpromoted_value unprom[2]; tree half_type; if (!vect_widened_op_tree (vinfo, last_stmt_info, orig_code, orig_code, - shift_p, 2, unprom, &half_type, subtype)) + shift_p, 2, unprom, &half_type)) return NULL; @@ -1484,13 +1483,11 @@ static gimple * vect_recog_widen_op_pattern (vec_info *vinfo, stmt_vec_info last_stmt_info, tree *type_out, tree_code orig_code, internal_fn wide_ifn, - bool shift_p, const char *name, - optab_subtype *subtype = NULL) + bool shift_p, const char *name) { combined_fn ifn = as_combined_fn (wide_ifn); return vect_recog_widen_op_pattern (vinfo, last_stmt_info, type_out, - orig_code, ifn, shift_p, name, - subtype); + orig_code, ifn, shift_p, name); } @@ -1513,11 +1510,9 @@ static gimple * vect_recog_widen_plus_pattern (vec_info *vinfo, stmt_vec_info last_stmt_info, tree *type_out) { - optab_subtype subtype; return vect_recog_widen_op_pattern (vinfo, last_stmt_info, type_out, PLUS_EXPR, IFN_VEC_WIDEN_PLUS, - false, "vect_recog_widen_plus_pattern", - &subtype); + false, "vect_recog_widen_plus_pattern"); } /* Try to detect subtraction on widened inputs, converting MINUS_EXPR @@ -1526,11 +1521,9 @@ static gimple * vect_recog_widen_minus_pattern (vec_info *vinfo, stmt_vec_info last_stmt_info, tree *type_out) { - optab_subtype subtype; return vect_recog_widen_op_pattern (vinfo, last_stmt_info, type_out, MINUS_EXPR, IFN_VEC_WIDEN_MINUS, - false, "vect_recog_widen_minus_pattern", - &subtype); + false, "vect_recog_widen_minus_pattern"); } /* Function vect_recog_ctz_ffs_pattern