From patchwork Tue Jun 14 10:49:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1643237 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=ZpQyr5yo; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LMld766JVz9sGJ for ; Tue, 14 Jun 2022 20:52:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B4B44386CE6D for ; Tue, 14 Jun 2022 10:52:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4B44386CE6D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1655203942; bh=aA5+IQZfMgmvZDKbooE5+ob+ZSRZnO7BkTwpxu7wpJA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZpQyr5yoAmeiqMdOmYEt323Ze5qCOIUZMY3vAaiktOYbe81ulpamJghzjzgMykVw9 HKI4WwF/4PLDI5eyAuWy9wLYlndC9vgwhEPn1fKrGXHp5ZHXmQJqO1w7T8dNgk4r6Z iAnJWY+RAx/x0QIdspRhF1JXHwVzXibRR9bOKWTI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id A11753850239 for ; Tue, 14 Jun 2022 10:49:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A11753850239 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D3B2521B4D for ; Tue, 14 Jun 2022 10:49:52 +0000 (UTC) Received: from [10.168.4.8] (unknown [10.168.4.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id CD2242C141 for ; Tue, 14 Jun 2022 10:49:52 +0000 (UTC) Date: Tue, 14 Jun 2022 12:49:52 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] middle-end/105965 - add missing v_c_e <{ el }> simplification MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, MISSING_MID, SPF_HELO_NONE, SPF_PASS, 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Message-Id: <20220614105222.B4B44386CE6D@sourceware.org> When we got the simplification of bit-field-ref to view-convert we lost the ability to detect FMAs since we cannot look through _1 = {_10}; _11 = VIEW_CONVERT_EXPR(_1); the following amends the (view_convert CONSTRUCTOR) pattern to handle this case. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2022-06-14 Richard Biener PR middle-end/105965 * match.pd (view_convert CONSTRUCTOR): Handle single-element CTOR case. * gcc.target/i386/pr105965.c: New testcase. --- gcc/match.pd | 17 +++++++++++++---- gcc/testsuite/gcc.target/i386/pr105965.c | 12 ++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr105965.c diff --git a/gcc/match.pd b/gcc/match.pd index 44a385b912d..776c9c6489a 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3669,12 +3669,21 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && TYPE_UNSIGNED (TREE_TYPE (@1))))) (view_convert @1))) -/* Simplify a view-converted empty constructor. */ +/* Simplify a view-converted empty or single-element constructor. */ (simplify (view_convert CONSTRUCTOR@0) - (if (TREE_CODE (@0) != SSA_NAME - && CONSTRUCTOR_NELTS (@0) == 0) - { build_zero_cst (type); })) + (with + { tree ctor = (TREE_CODE (@0) == SSA_NAME + ? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0)) : @0); } + (switch + (if (CONSTRUCTOR_NELTS (ctor) == 0) + { build_zero_cst (type); }) + (if (CONSTRUCTOR_NELTS (ctor) == 1 + && VECTOR_TYPE_P (TREE_TYPE (ctor)) + && operand_equal_p (TYPE_SIZE (type), + TYPE_SIZE (TREE_TYPE + (CONSTRUCTOR_ELT (ctor, 0)->value)))) + (view_convert { CONSTRUCTOR_ELT (ctor, 0)->value; }))))) /* Re-association barriers around constants and other re-association barriers can be removed. */ diff --git a/gcc/testsuite/gcc.target/i386/pr105965.c b/gcc/testsuite/gcc.target/i386/pr105965.c new file mode 100644 index 00000000000..5bb53790de8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr105965.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mfma -mfpmath=sse" } */ + +typedef float v1sf __attribute__((vector_size(4))); + +v1sf +foo43 (v1sf a, v1sf b, v1sf c) +{ + return a * b + c; +} + +/* { dg-final { scan-assembler "fmadd" } } */