From patchwork Fri Mar 16 08:17:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janne Blomqvist X-Patchwork-Id: 147152 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 50AC5B6FAB for ; Fri, 16 Mar 2012 19:18:00 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1332490681; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=f3Je8Qe5x6pqcm4wxqjQnu7YQ2g=; b=r/LYGOxGkXlQ68bAnbFCL9I9GMa+6yO5xh8eG0o09hdoUzwP3O/q0WOi5qzvZA FkdJYrTQKt8LAFPE/Je+JV+3844jCICxt0bKjFSmrhsYg8boMlzsMn/FStKKB4wT MgidCnmsLCrNNQrIm6bp9ZRY4OFYdWouuKbFH6bi8cjCw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=UB+tR3N9kPBjwp9qTa1Vi5BXTCn4A4HCVFcyfevtQs9iNRXx0Sr2EY8hFOmF0h 6jIL/D8JZ4XmKgnZfhCC86YSDTzIDWa+iAMFLBmtIGDYAYy3izI+M8AXm2FF5NYS 950Wp9wNwroAfW4TIN0I8AE2vnZqOjlFH10/fSHxFt93o=; Received: (qmail 11673 invoked by alias); 16 Mar 2012 08:17:46 -0000 Received: (qmail 11642 invoked by uid 22791); 16 Mar 2012 08:17:36 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-lb0-f175.google.com (HELO mail-lb0-f175.google.com) (209.85.217.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Mar 2012 08:17:19 +0000 Received: by lbbgi4 with SMTP id gi4so2068166lbb.20 for ; Fri, 16 Mar 2012 01:17:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.42.35 with SMTP id k3mr623384lbl.98.1331885836529; Fri, 16 Mar 2012 01:17:16 -0700 (PDT) Received: by 10.152.129.105 with HTTP; Fri, 16 Mar 2012 01:17:16 -0700 (PDT) In-Reply-To: References: <4F624DB8.4010600@net-b.de> Date: Fri, 16 Mar 2012 10:17:16 +0200 Message-ID: Subject: Re: [Patch, fortran] Use BUILT_IN_IROUND From: Janne Blomqvist To: Tobias Burnus Cc: Fortran List , GCC Patches Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Thu, Mar 15, 2012 at 22:28, Janne Blomqvist wrote: > On Thu, Mar 15, 2012 at 22:14, Tobias Burnus wrote: >> Janne Blomqvist wrote: >>> >>> since some time GCC has BUILT_IN_IROUND{F,,L}, similar to lround() and >>> llround() but the result is returned as an integer. >>> >>> Regtested on x86_64-unknown-linux-gnu, Ok for trunk? >> >> >> OK. Thanks for the patch! Nit: Could you check mathbuiltins.def - at least >> in the diff, "iround" seems to be misaligned (one " " missing). > > Ah, a tab had sneaked in, fixed. Committed the fixed patch as r185442. > Thanks for the quick review! > > -- > Janne Blomqvist I realized there was a bug in the patch, and testing revealed my suspicion as true. Namely as there is no library fallback for iround, and the middle-end machinery takes care of converting it to lround only for float, double, and long double, it doesn't work for __float128. In the testcase in my original patch mail, changing x to real(16) generated a call to iroundq, which doesn't exist. Committed the patch below as obvious. else if (resprec <= LONG_TYPE_SIZE) fn = builtin_decl_for_precision (BUILT_IN_LROUND, argprec); Index: ChangeLog =================================================================== --- ChangeLog (revision 185452) +++ ChangeLog (working copy) @@ -1,3 +1,8 @@ +2012-03-16 Janne Blomqvist + + * trans-intrinsic.c (build_round_expr): Don't use BUILT_IN_IROUND + for __float128. + 2012-03-15 Janne Blomqvist * f95-lang.c (gfc_init_builtin_functions): Initialize Index: trans-intrinsic.c =================================================================== --- trans-intrinsic.c (revision 185452) +++ trans-intrinsic.c (working copy) @@ -383,10 +383,11 @@ build_round_expr (tree arg, tree restype resprec = TYPE_PRECISION (restype); /* Depending on the type of the result, choose the int intrinsic - (iround, available only as a builtin), long int intrinsic (lround - family) or long long intrinsic (llround). We might also need to - convert the result afterwards. */ - if (resprec <= INT_TYPE_SIZE) + (iround, available only as a builtin, therefore cannot use it for + __float128), long int intrinsic (lround family) or long long + intrinsic (llround). We might also need to convert the result + afterwards. */ + if (resprec <= INT_TYPE_SIZE && argprec <= LONG_DOUBLE_TYPE_SIZE) fn = builtin_decl_for_precision (BUILT_IN_IROUND, argprec);