From patchwork Fri Feb 6 02:30:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 436988 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 3226A14028F for ; Fri, 6 Feb 2015 13:31:13 +1100 (AEDT) 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=e063+4j9OczWlQju1AAIgMFRp1Lr5 UckuYBOTDxbnLiEyeDJCTuH36tGPD8taWLmJSTz8ArBlPznH+uDEV9orhdXvGo48 HDCJomCHjxzPU+1kTL79FNnRj83kJsHpOLc5lgdhLY/NRbPdFZty+kMyFkdHBvqA ajxwyVDiqqX37k= 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=MeoRTtJql6cw4KTEx/Mm/Hw+mE4=; b=kQZ Su8ziuvEwVPx5I0DgfzWnS9rIAhDiw0Fn7oACrMuUxFZU3DZWWW3+zNwQgjbD1y6 56mRwY1hPzbuSOt64Ov5MsIc994fo2xZCRQUWfCt2HQc894GC39oQhNinEFoMCiq SpQF/hOOagTw3zrCkxFU8Ip5orrMzxqYoWx+m/lU= Received: (qmail 16570 invoked by alias); 6 Feb 2015 02:30:36 -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 16510 invoked by uid 89); 6 Feb 2015 02:30:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Fri, 6 Feb 2015 02:30:19 +0000 From: Joseph Myers To: Subject: soft-fp: Fix _FP_FMA when product is zero and third argument is finite (bug 17932) Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 soft-fp's _FP_FMA fails to set the result's exponent for cases where the result of the multiplication is 0, yielding incorrect (arbitrary, depending on uninitialized values) results for those cases. This affects libm for architectures using soft-fp to implement fma. This patch adds the exponent setting and tests for this case. Tested for ARM soft-float (which uses soft-fp fma), x86_64 and x86 (to verify not introducing new libm test failures there). Will commit when master reopens. (This bug showed up in testing my patch to move the Linux kernel to current soft-fp. math/Makefile has "override CFLAGS += -Wno-uninitialized" which would have stopped compiler warnings from showing up this problem, although I wouldn't be surprised if removing that shows spurious warnings from this code, if the compiler fails to follow that various cases where the exponent is uninitialized don't need it initialized because the class is set to a value meaning the uninitialized exponent isn't used.) (auto-libm-test-out diffs omitted below.) 2015-02-06 Joseph Myers [BZ #17932] * soft-fp/op-common.h (_FP_FMA): Set exponent of result in case where multiplication results in zero and third argument is finite and nonzero. * math/auto-libm-test-in: Add more tests of fma. * math/auto-libm-test-out: Regenerated. diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in index 8db3eb6..ad43113 100644 --- a/math/auto-libm-test-in +++ b/math/auto-libm-test-in @@ -1024,6 +1024,16 @@ fma 1.0 -1.0 1.0 fma -1.0 1.0 1.0 fma -1.0 -1.0 -1.0 +fma 0 0 1 +fma 0 0 2 +fma 0 0 max +fma 0 1 1 +fma 1 0 1 +fma 0 1 2 +fma 1 0 2 +fma 0 1 max +fma 1 0 max + # Bug 6801: errno setting may be missing. fma min min 0 missing-errno fma min min -0 missing-errno diff --git a/soft-fp/op-common.h b/soft-fp/op-common.h index 6b8b52f..d115f58 100644 --- a/soft-fp/op-common.h +++ b/soft-fp/op-common.h @@ -1116,6 +1116,7 @@ R##_s = Z##_s; \ _FP_FRAC_COPY_##wc (R, Z); \ R##_c = Z##_c; \ + R##_e = Z##_e; \ break; \ \ case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_INF): \