From patchwork Thu Jul 3 18:00:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1910 Received: (qmail 13753 invoked by alias); 3 Jul 2014 18:01:56 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 13060 invoked by uid 89); 3 Jul 2014 18:01:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_50, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qc0-f174.google.com X-Received: by 10.224.172.201 with SMTP id m9mr10234371qaz.32.1404410459568; Thu, 03 Jul 2014 11:00:59 -0700 (PDT) From: Richard Henderson To: libc-alpha@sourceware.org Subject: [COMMITTED 2/4] alpha: Fix lround implementations Date: Thu, 3 Jul 2014 11:00:44 -0700 Message-Id: <1404410446-30243-2-git-send-email-rth@twiddle.net> In-Reply-To: <1404410446-30243-1-git-send-email-rth@twiddle.net> References: <1404410446-30243-1-git-send-email-rth@twiddle.net> Use chopped rounding to add 0.5. --- ChangeLog | 3 +++ sysdeps/alpha/fpu/s_lround.c | 8 ++++---- sysdeps/alpha/fpu/s_lroundf.c | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) * sysdeps/alpha/fpu/s_lround.c: Add 0.5 with chopped rounding. * sysdeps/alpha/fpu/s_lroundf.c: Likewise. diff --git a/sysdeps/alpha/fpu/s_lround.c b/sysdeps/alpha/fpu/s_lround.c index dedb98e..52a88b6 100644 --- a/sysdeps/alpha/fpu/s_lround.c +++ b/sysdeps/alpha/fpu/s_lround.c @@ -25,11 +25,11 @@ long int __lround (double x) { - double adj; + double adj, y; - adj = 0x1.fffffffffffffp-2; /* nextafter (0.5, 0.0) */ - adj = copysign (adj, x); - return x + adj; + adj = copysign (0.5, x); + asm("addt/suc %1,%2,%0" : "=&f"(y) : "f"(x), "f"(adj)); + return y; } strong_alias (__lround, __llround) diff --git a/sysdeps/alpha/fpu/s_lroundf.c b/sysdeps/alpha/fpu/s_lroundf.c index 650004d..ebbb129 100644 --- a/sysdeps/alpha/fpu/s_lroundf.c +++ b/sysdeps/alpha/fpu/s_lroundf.c @@ -25,11 +25,11 @@ long int __lroundf (float x) { - float adj; + float adj, y; - adj = 0x1.fffffep-2; /* nextafterf (0.5f, 0.0f) */ - adj = copysignf (adj, x); - return x + adj; + adj = copysignf (0.5f, x); + asm("adds/suc %1,%2,%0" : "=&f"(y) : "f"(x), "f"(adj)); + return y; } strong_alias (__lroundf, __llroundf)