From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101743 invoked by alias); 17 Sep 2019 21:16:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 101734 invoked by uid 89); 17 Sep 2019 21:16:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=nearest X-HELO: esa4.mentor.iphmx.com Received: from esa4.mentor.iphmx.com (HELO esa4.mentor.iphmx.com) (68.232.137.252) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Sep 2019 21:16:56 +0000 IronPort-SDR: c5OCmsvHEVyoQKlzL6qpSG0n0ukGDUAMgUHOOyo5OnOqDVnk4xKpFc9OzPh7YxldAV3qKPKTum T3PwJ4I3SVkc9riNGlaO6STY/MH6nRpq/v1xBRcKTXRBV7/xlX6TO7/mYzLFlmq0lQElk0rLxy JK7A7Z/jEg9K/z/Fc91qEPv31EDiX66Tgl911u4q0W1nPYCj1b5fLx9dvw5kz0PKq/LJZROIIb A2ErnYpn4FIvG8xryofnSpbe0BPixIkjPilOz47Wxxylrvv+02aS5vSwTKMUUef4NGFwb7Bbh8 O2U= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 17 Sep 2019 13:16:54 -0800 IronPort-SDR: vhdFUwenXoht9xZJQR7T71b9CYXireEtn57InZR4/znr17cSWzdqfYS+aOHL3fqZW+V3Mne3iL OPnMMWpBvSpF0Vx6YDlXfuocUVJ1YwrLGYAmCvikDD1bvS5XyK9dAEW1lzCliVavD/dwP6A0BP 74Awstt5GzJfJNYhLy6Fgi9xnlUdd/kvklj+Swk7Z+YZcNlehUyKL9iaDBbqKlxHSpC2IE7KS+ LOyvmVjdKDzSmyq7nhFuPjyD0vyrUn2D84DkH283p7+3hX6XFVIAq80QNjXW5Aynxxu4Z0Jhti bvs= Date: Tue, 17 Sep 2019 21:16:00 -0000 From: Joseph Myers To: Jakub Jelinek CC: Richard Biener , Subject: Re: [PATCH] Fix up sqrt(x) < c and sqrt(x) >= c match.pd folding (PR tree-optimization/91734) In-Reply-To: <20190914004014.GE25273@laptop.zalov.cz> Message-ID: References: <20190914004014.GE25273@laptop.zalov.cz> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Return-Path: joseph@codesourcery.com X-SW-Source: 2019-09/txt/msg01033.txt.bz2 On Sat, 14 Sep 2019, Jakub Jelinek wrote: > Hi! > > As mentioned in the PR, the sqrt (x) < c optimization into x < c*c > sometimes breaks the boundary case, if c2=c*c is inexact then in some cases > we need to optimize it into x <= c*c rather than x < c*c. The original And in some cases the boundary case is wrong in the other direction and we need to optimize it into x < nextdown (c*c). For example, say c == 0x1.001002p+0f; (double) c * c == 0x1.002005004004p+0, and rounding to nearest float gives c * c == 0x1.002006p+0f, so nextdownf (c * c) == 0x1.002004p+0f; in double precision, sqrt (0x1.002004p+0f) == 0x1.0010017fe8006p+0, and rounding to nearest float gives c again. So x < c*c does not in fact imply sqrt (x) < c in that case. -- Joseph S. Myers joseph@codesourcery.com