From patchwork Thu Oct 5 14:41:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Thevenoux X-Patchwork-Id: 114947 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp669034qgn; Thu, 5 Oct 2017 07:41:33 -0700 (PDT) X-Google-Smtp-Source: AOwi7QALL+dxGlY967PvPzaPwoQyb2OPDdDSmSrB/bmW9a6vFV8cyol4LpO7tfH2yhKG7/02gPal X-Received: by 10.159.245.129 with SMTP id a1mr18134937pls.394.1507214493312; Thu, 05 Oct 2017 07:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507214493; cv=none; d=google.com; s=arc-20160816; b=bkooUjO4Bhoixx63aASAICsemYvKWmbpxgaV8gE2O0isXTnddiYNGgPSoLqEt0coli Pm6XASsagPerxrIjwxFRjOEgUntg8ls3seX8/t78wzbilRWmJ1RXoBQXPsj7pN42qTYm Ab99ALMbCu72fhFAfvLS4yrFjNgcKy099+cUzeCMT6pQb5GQWMtp0Iincf8RhbWUIoBe /X76Do7gPvdplBODzMbdyK0EnDLg86fj84cVuasz3yKUwFCxcfwHSO7hQ1dLq6KBp8EM nx0Y+9l6nkVoKCqFHHwWUwkxrb4pu+q+/kLUfFkhbpbp7uVR46+myWg+pZgtlz/O4438 ffKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:subject:in-reply-to:message-id:to:from:date :delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=42ytww1ZK0NYNI+NadQ0VybnA+2jMSAeGJ/OEkCdcho=; b=YPDVlVx2/eFHtcs+uVu42FM5D1ZLJfRbhCdQy/KVsEsmpPBGL98ygWqksum9mygn9Y IAQ8/OTvRRK6Vz0pQb0LSgkfu4qwXqpSaxzLoyOI4ONAFjVAooyeSnKFoBt2HWorRd17 Q0gJ5g/tubRhjXv6XsOAMaAClDzxOzolHgsWHXFX83r0kdLyIa5DlbvA3tRg9YDy/qdA gGXodTxs1UhAT/LXQ7f9s81WGX3IIBoxamTGngTqLZY7jluYsQF1EO2MgeAqj78U6LT2 Y2jLp7S/v28OODlKG2SwvuFV+1A7hqxrBywPyP9/4CK3t4m1yhmPcm/OmAKSyXqF6wLE V4Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vOwaSWFa; spf=pass (google.com: domain of gcc-patches-return-463538-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-463538-patch=linaro.org@gcc.gnu.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e14si2185702pgt.216.2017.10.05.07.41.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 07:41:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-463538-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vOwaSWFa; spf=pass (google.com: domain of gcc-patches-return-463538-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-463538-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:message-id:in-reply-to:subject:mime-version :content-type; q=dns; s=default; b=KubYtfsX+I0HWE+s2mtpAWkBet/uC P+xZYhMd3AnK9XbvZe2LKgCc7ZBLyZHEfF/IX4fRJsrN5pQchV75hidQF32fm/Le PTzLcKlQVnzQFahu1W4P99IBg2jBAJbdgPIECRSphTl5gR4OTbd0wmmoTWB+lKMt VVnCoPgWBaeFgw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:message-id:in-reply-to:subject:mime-version :content-type; s=default; bh=x4BhzhoRZpzzj3x7+X/XvtX++fk=; b=vOw aSWFaGQgvpvvjevF6a3jjUeQUjYG4JZz5lLO2nfA8hb48UXHkETrscFstZePGOCy C6xZCHcYz9kgJ8dh++IaV2r/qwKXCDvM3JNFgT1t3rQy6Ldi7jLHG+zCzEKmQm6/ GbyDPY/+UEW6D9YQqs6PJIdebo6GyXE5h6P/XBcw= Received: (qmail 119883 invoked by alias); 5 Oct 2017 14:41:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 119869 invoked by uid 89); 5 Oct 2017 14:41:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-22.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=laurent, Laurent, H*M:zimbra, H*c:PHrt X-HELO: mail3-relais-sop.national.inria.fr Received: from mail3-relais-sop.national.inria.fr (HELO mail3-relais-sop.national.inria.fr) (192.134.164.104) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Oct 2017 14:41:16 +0000 Received: from zmbs7.inria.fr ([128.93.142.20]) by mail3-relais-sop.national.inria.fr with ESMTP; 05 Oct 2017 16:41:14 +0200 Date: Thu, 5 Oct 2017 16:41:14 +0200 (CEST) From: Laurent Thevenoux To: gcc-patches@gcc.gnu.org Message-ID: <241978471.13145496.1507214474104.JavaMail.zimbra@inria.fr> In-Reply-To: <518273718.13144082.1507214398559.JavaMail.zimbra@inria.fr> Subject: tree-complex.c: fix some_nonzerop test over reals (and a bug fix) MIME-Version: 1.0 Hello, This patch improves the some_nonzerop(tree t) function from tree-complex.c file (the function is only used there). This function returns true if a tree as a parameter is not the constant 0 (or +0.0 only for reals when !flag_signed_zeros ). The former result is then used to determine if some simplifications are possible for complex expansions (addition, multiplication, and division). Unfortunately, if the tree is a real constant, the function always return true, even for +0.0 because of the explicit test on flag_signed_zeros (so if your system enables signed zeros you cannot benefit from those simplifications). To avoid this behavior and allow complex expansion simplifications, I propose the following patch, which test for the sign of the real constant 0.0 instead of checking the flag. This first fix reveals a bug (thanks to c-c++-common/torture/complex-sign-add.c ) in the simplification section of expand_complex_addition (also fixed in the patch). The patch has passed bootstrap and testing on x86_64-pc-linux-gnu . Best regards, Laurent Thévenoux diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2191d62..a6124ce 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-10-05 Laurent Thévenoux + + * tree-complex.c (some_nonzerop): Adjust the way of testing real + constants. Allows existing simplifications of complex expansions + to be well done. + * tree-complex.c (expand_complex_addition): Bug fixing for complex + addition expansion simplification. + 2017-10-02 Bill Schmidt Backport from mainline diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index e0dd3d9..413b601 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -110,8 +110,11 @@ some_nonzerop (tree t) /* Operations with real or imaginary part of a complex number zero cannot be treated the same as operations with a real or imaginary operand if we care about the signs of zeros in the result. */ - if (TREE_CODE (t) == REAL_CST && !flag_signed_zeros) - zerop = real_identical (&TREE_REAL_CST (t), &dconst0); + if (TREE_CODE (t) == REAL_CST) + { + if (real_identical (&TREE_REAL_CST (t), &dconst0)) + zerop = !real_isneg (&TREE_REAL_CST (t)); + } else if (TREE_CODE (t) == FIXED_CST) zerop = fixed_zerop (t); else if (TREE_CODE (t) == INTEGER_CST) @@ -937,7 +940,7 @@ expand_complex_addition (gimple_stmt_iterator *gsi, tree inner_type, case PAIR (VARYING, ONLY_REAL): rr = gimplify_build2 (gsi, code, inner_type, ar, br); - ri = ai; + ri = bi; break; case PAIR (VARYING, ONLY_IMAG):