From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15370 invoked by alias); 15 Jan 2014 16:13:18 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 15359 invoked by uid 89); 15 Jan 2014 16:13:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 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 (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 15 Jan 2014 16:13:16 +0000 Received: from stedding.saclay.inria.fr ([193.55.250.194]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 15 Jan 2014 17:13:12 +0100 Received: from glisse (helo=localhost) by stedding.saclay.inria.fr with local-esmtp (Exim 4.82) (envelope-from ) id 1W3T5c-00075K-L8; Wed, 15 Jan 2014 17:13:12 +0100 Date: Wed, 15 Jan 2014 16:13:00 -0000 From: Marc Glisse Reply-To: gcc-help@gcc.gnu.org To: Jay Foad cc: gcc-help@gcc.gnu.org Subject: Re: why does gcc need -fno-trapping-math to generate roundsd instructions? In-Reply-To: Message-ID: References: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-SW-Source: 2014-01/txt/msg00060.txt.bz2 On Tue, 14 Jan 2014, Jay Foad wrote: > I'm using GCC 4.8.1 with eglibc 2.17 on an Intel CPU with SSE 4.1. > > Given this source: > > #include > double f(double x){return floor x;} > > gcc -msse4.1 -O -S generates: > > f: > subq $8, %rsp > call floor > addq $8, %rsp > ret > > It seems I need to add -fno-trapping-math to get inline code: > > f: > roundsd $1, %xmm0, %xmm0 > ret > > But why? If I run the first version under a debugger, the call to > "floor" eventually resolves to eglibc's __floor_sse41, which just does > this: > > roundsd $0x1,%xmm0,%xmm0 > retq > > So what is -ftrapping-math really buying me? Why can't the compiler > generate roundsd inline in all cases? First, I think you want to file a PR on bugzilla, or your message will just be forgotten. The reason could be related to this note in the glibc manpage: "SUSv2 and POSIX.1-2001 contain text about overflow (which might set errno to ERANGE, or raise an FE_OVERFLOW exception). In practice, the result cannot overflow on any current machine, so this error-handling stuff is just nonsense." -- Marc Glisse