From patchwork Wed Aug 5 15:03:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 504042 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 163521402D9 for ; Thu, 6 Aug 2015 01:03:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=IqTaw4QO; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=qiMg8mEHZK0ukjY7o46bQ0lCEbw8i z4JuU1C4C8P9ghmr67lvktIO6ZEJeW0KaE/bV5mOEoJGuEWO+FhABMP5PFcHY5FY hZqPAvk+fP3PF2k8cACPemUVJU3QCGAKVs8YNcUbMLHPHwZCTs6rHdBM5bFb7m0H wA8V2nIffmqW/A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=tVoo2dw03C/c5p6QMUJJBwN6mAM=; b=IqT aw4QOr0fUtUWsFntRfX6J+V/y07XSh5/xiGHP7f2au2HMIpYVyoxqUcIeMUjS0/Q v0vdjR06t+VoN8fYUX9U8H587DrqW0UhZYqOicbOSnQ8ODk0Md60OOedrAWgZYUK MUVM/9BdqGSUXV1ks/hWpWxYagMgQZHwKBX5PpRw= Received: (qmail 64828 invoked by alias); 5 Aug 2015 15:03:22 -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 64815 invoked by uid 89); 5 Aug 2015 15:03:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, KAM_LOTSOFHASH, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Wed, 5 Aug 2015 15:03:14 +0000 From: Joseph Myers To: Subject: Fix powf (close to -1, large) (bug 18647) [committed] Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 The flt-32 implementation of powf wrongly uses x-1 instead of |x|-1 when computing log (x) for the case where |x| is close to 1 and y is large. This patch fixes the logic accordingly. Relevant tests existed for x close to 1, and corresponding tests are added for x close to -1, as well as for some new variant cases. Tested for x86_64 and x86. Committed. (auto-libm-test-out diffs omitted below.) 2015-08-05 Joseph Myers [BZ #18647] * sysdeps/ieee754/flt-32/e_powf.c (__ieee754_powf): For large y and |x| close to 1, use absolute value of x when computing log. * math/auto-libm-test-in: Add more tests of pow. * math/auto-libm-test-out: Regenerated. diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in index f783c5b..c17f6f5 100644 --- a/math/auto-libm-test-in +++ b/math/auto-libm-test-in @@ -2361,6 +2361,46 @@ pow 0x0.ffffffffffffffffffffffffffff8p0 -0x1.23456789abcdef0123456789abcdp126 pow 0x1.0000000000000000000000000001p0 0x1.23456789abcdef0123456789abcdp125 pow 0x1.0000000000000000000000000001p0 -0x1.23456789abcdef0123456789abcdp125 +pow -0x0.ffffffp0 10 +pow -0x0.ffffffp0 100 +pow -0x0.ffffffp0 1000 +pow -0x0.ffffffp0 0x1p24 +pow -0x0.ffffffp0 0x1p30 +pow -0x0.ffffffp0 0x1.234566p30 +pow -0x0.ffffffp0 -10 +pow -0x0.ffffffp0 -100 +pow -0x0.ffffffp0 -1000 +pow -0x0.ffffffp0 -0x1p24 +pow -0x0.ffffffp0 -0x1p30 +pow -0x0.ffffffp0 -0x1.234566p30 +pow -0x1.000002p0 0x1p24 +pow -0x1.000002p0 0x1.234566p29 +pow -0x1.000002p0 -0x1.234566p29 + +pow -0x0.fffffffffffff8p0 0x1.23456789abcdfp62 +pow -0x0.fffffffffffff8p0 -0x1.23456789abcdfp62 +pow -0x1.0000000000001p0 0x1.23456789abcdfp61 +pow -0x1.0000000000001p0 -0x1.23456789abcdfp61 + +pow -0x0.ffffffffffffffffp0 0x1.23456789abcdef0ep77 +pow -0x0.ffffffffffffffffp0 -0x1.23456789abcdef0ep77 +pow -0x1.0000000000000002p0 0x1.23456789abcdef0ep76 +pow -0x1.0000000000000002p0 -0x1.23456789abcdef0ep76 + +pow -0x0.ffffffffffffffffffffffffffff8p0 0x1.23456789abcdef0123456789abcdp126 +pow -0x0.ffffffffffffffffffffffffffff8p0 -0x1.23456789abcdef0123456789abcdp126 +pow -0x1.0000000000000000000000000001p0 0x1.23456789abcdef0123456789abcdp125 +pow -0x1.0000000000000000000000000001p0 -0x1.23456789abcdef0123456789abcdp125 + +pow 0x1.000002p0 0x1p30 +pow -0x1.000002p0 0x1p30 +pow 0x1.000002p0 max +pow -0x1.000002p0 max +pow 0x1.00000ep0 0x1p30 +pow -0x1.00000ep0 0x1p30 +pow 0x1.00000ep0 max +pow -0x1.00000ep0 max + pow 1e4932 0.75 pow 1e4928 0.75 pow 1e4924 0.75 diff --git a/sysdeps/ieee754/flt-32/e_powf.c b/sysdeps/ieee754/flt-32/e_powf.c index 12c408f..8e8d918 100644 --- a/sysdeps/ieee754/flt-32/e_powf.c +++ b/sysdeps/ieee754/flt-32/e_powf.c @@ -131,7 +131,7 @@ __ieee754_powf(float x, float y) if(ix>0x3f800007) return (hy>0)? huge*huge:tiny*tiny; /* now |1-x| is tiny <= 2**-20, suffice to compute log(x) by x-x^2/2+x^3/3-x^4/4 */ - t = x-1; /* t has 20 trailing zeros */ + t = ax-1; /* t has 20 trailing zeros */ w = (t*t)*((float)0.5-t*((float)0.333333333333-t*(float)0.25)); u = ivln2_h*t; /* ivln2_h has 16 sig. bits */ v = t*ivln2_l-w*ivln2;