From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40451 invoked by alias); 20 Aug 2019 15:12:59 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 40442 invoked by uid 89); 20 Aug 2019 15:12:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy=H*f:sk:mpt8srn, H*i:sk:mpt8srn, structural X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Aug 2019 15:12:58 +0000 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 9810628; Tue, 20 Aug 2019 08:12:56 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.99.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A70F43F246; Tue, 20 Aug 2019 08:12:55 -0700 (PDT) From: Richard Sandiford To: Segher Boessenkool Mail-Followup-To: Segher Boessenkool ,Tejas Joshi , gcc@gcc.gnu.org, Martin Jambor , hubicka@ucw.cz, joseph@codesourcery.com, richard.sandiford@arm.com Cc: Tejas Joshi , gcc@gcc.gnu.org, Martin Jambor , hubicka@ucw.cz, joseph@codesourcery.com Subject: Re: Expansion of narrowing math built-ins into power instructions References: <20190815184450.GO31406@gate.crashing.org> <20190819130720.GG31406@gate.crashing.org> <20190820121137.GP31406@gate.crashing.org> <20190820134613.GR31406@gate.crashing.org> Date: Tue, 20 Aug 2019 15:12:00 -0000 In-Reply-To: (Richard Sandiford's message of "Tue, 20 Aug 2019 15:43:43 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00160.txt.bz2 Richard Sandiford writes: >> And yes, it is icky. But it is sound, as far as I can see. > > I really disagree that it's sound, but no point me saying why again :-) > > (It could certainly be made to work with sufficient hacks of course, > like pretty much anything could, but I don't think that's the same thing.) For an example, we have: /* Maybe simplify x + 0 to x. The two expressions are equivalent when x is NaN, infinite, or finite and nonzero. They aren't when x is -0 and the rounding mode is not towards -infinity, since (-0) + 0 is then 0. */ if (!HONOR_SIGNED_ZEROS (mode) && trueop1 == CONST0_RTX (mode)) return op0; I think it's plausible that people will care about accurate rounding but not signed zeroes. In that mode we could have: (set (reg:DF r3) (plus:DF (reg:DF r1) (reg:DF r2))) (set (reg:DF r4) (const_double:DF 0.0)) (set (reg:SF r5) (float_narrow:SF (plus:DF (reg:DF r3) (reg:DF r4)))) Then combine through normal structural simplification could (with the rule above) fold all this down to: (set (reg:SF r5) (float_narrow:SF (plus:DF (reg:DF r1) (reg:DF r2)))) where the truncation is now fused with r1+r2 instead of r3+r4. We would have to have to add specific checks to avoid this happening, it wouldn't fall out naturally from structural PoV. Thanks, Richard