From patchwork Wed Apr 13 13:45:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1616770 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=O/LzI9Z2; dkim-atps=neutral Authentication-Results: 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=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KdkRz2Kljz9sFv for ; Wed, 13 Apr 2022 23:47:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2795C3857346 for ; Wed, 13 Apr 2022 13:47:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2795C3857346 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1649857659; bh=jpxZIxo2XU60Vdjx1tng8OCQI7b/C8aalMNxo7merPc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=O/LzI9Z2AqzIvj4r3NvrWfuay7FNXLx3kBTOwX7PBXfh/RhWxVvd73artIsKPl4uS pbVxxXxe5J8c7tIp+23ctdKrMHNANjF2fubee9DkEPVl5vEDMPx7RCu3qgeQg10FT0 x7tf70/daDLVFZPIZ016xiw7b1MwIpTgEy/EQuas= 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 42F85385AC22 for ; Wed, 13 Apr 2022 13:45:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 42F85385AC22 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A2075210DB for ; Wed, 13 Apr 2022 13:45:47 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8E93813AB8 for ; Wed, 13 Apr 2022 13:45:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gC6VIQvUVmJJBwAAMHmgww (envelope-from ) for ; Wed, 13 Apr 2022 13:45:47 +0000 Date: Wed, 13 Apr 2022 15:45:47 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/105263 - reassoc and DFP MIME-Version: 1.0 Message-Id: <20220413134547.8E93813AB8@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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" reassoc has certain tricks which in the end depend on the ability to undo them. For DFP creating a -1. constant is easy but re-identifying is appearantly not - real_minus_onep rejects those outright for DFP. So we have to disable (at least) this one trick. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2022-04-13 Richard Biener PR tree-optimization/105263 * tree-ssa-reassoc.cc (try_special_add_to_ops): Do not consume negates in multiplication chains with DFP. * gcc.dg/pr105263.c: New testcase. --- gcc/testsuite/gcc.dg/pr105263.c | 15 +++++++++++++++ gcc/tree-ssa-reassoc.cc | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr105263.c diff --git a/gcc/testsuite/gcc.dg/pr105263.c b/gcc/testsuite/gcc.dg/pr105263.c new file mode 100644 index 00000000000..5cb7fcd09a2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr105263.c @@ -0,0 +1,15 @@ +/* { dg-do compile { target dfp } } */ +/* { dg-options "-O -ffast-math -w -Wno-psabi" } */ + +typedef _Decimal64 __attribute__((__vector_size__ (8))) U; +typedef _Decimal64 __attribute__((__vector_size__ (16))) V; + +V v; + +U +foo (U u) +{ + u *= u; + u *= -(U){ v[1] }; + return u; +} diff --git a/gcc/tree-ssa-reassoc.cc b/gcc/tree-ssa-reassoc.cc index 4ab3c3361f9..f41b3c9a004 100644 --- a/gcc/tree-ssa-reassoc.cc +++ b/gcc/tree-ssa-reassoc.cc @@ -5857,7 +5857,9 @@ try_special_add_to_ops (vec *ops, && gimple_assign_rhs_code (def_stmt) == NEGATE_EXPR && !HONOR_SNANS (TREE_TYPE (op)) && (!HONOR_SIGNED_ZEROS (TREE_TYPE (op)) - || !COMPLEX_FLOAT_TYPE_P (TREE_TYPE (op)))) + || !COMPLEX_FLOAT_TYPE_P (TREE_TYPE (op))) + && (!FLOAT_TYPE_P (TREE_TYPE (op)) + || !DECIMAL_FLOAT_MODE_P (element_mode (op)))) { tree rhs1 = gimple_assign_rhs1 (def_stmt); tree cst = build_minus_one_cst (TREE_TYPE (op));