From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28733 invoked by alias); 1 Aug 2011 13:07:22 -0000 Received: (qmail 28719 invoked by uid 22791); 1 Aug 2011 13:07:21 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 01 Aug 2011 13:07:08 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/47990] Missed promotion of double precision constants to single precision for -funsafe-math-optimizations X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Mon, 01 Aug 2011 13:07:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg00025.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47990 --- Comment #2 from Richard Guenther 2011-08-01 13:07:00 UTC --- The intel compiler does not perform this optimization even at -fast. It does perform the demotion on float foo (float x, float y) { return (int)((float)(x/y + 0.5)) * y; } though, even with default optimization (also with the conversion to int removed or associated to apply to the first operand of the multiplication only). So they leave alone what looks like a usual "rounding" pattern. My original idea was to fold (int)((double)(x/y) + 0.5) to (int)(x/y + 0.5f), similar to (float)((double)(x/y) + 0.5) to (x/y + 0.5f) which we already do (at -O0, in convert_to_real).