From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30018 invoked by alias); 14 Jan 2014 14:53: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 30009 invoked by uid 89); 14 Jan 2014 14:53:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-we0-f180.google.com Received: from mail-we0-f180.google.com (HELO mail-we0-f180.google.com) (74.125.82.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 14 Jan 2014 14:53:16 +0000 Received: by mail-we0-f180.google.com with SMTP id q59so483687wes.39 for ; Tue, 14 Jan 2014 06:53:13 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.194.6.42 with SMTP id x10mr27651489wjx.17.1389711193344; Tue, 14 Jan 2014 06:53:13 -0800 (PST) Received: by 10.216.199.4 with HTTP; Tue, 14 Jan 2014 06:53:13 -0800 (PST) Date: Tue, 14 Jan 2014 14:53:00 -0000 Message-ID: Subject: why does gcc need -fno-trapping-math to generate roundsd instructions? From: Jay Foad To: gcc-help@gcc.gnu.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2014-01/txt/msg00051.txt.bz2 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? Thanks, Jay.