From patchwork Wed Mar 11 01:15:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 448755 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 EE47B140082 for ; Wed, 11 Mar 2015 12:15:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=sourceware.org header.i=@sourceware.org header.b=BM5RlckU; dkim-adsp=none (unprotected policy); 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=PV5pXFLNgw2N5vvZ4Gt64DaJrBvL5 67nQ//dV5x34fZQ2FeD9jVav+CEprymtZZWMBuItOJAw8VY9vaJg40a2LzpGNTRt N6ssJW2mfM5xiVhF+PY7fsqAfU2Pm+qF+UWx0f7X2yfsD0zEiXdQritgga2vqjKT KYebGnLOxdJ65g= 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=oWCrFtJEE/sE/2UMo5sFEIo3o5g=; b=BM5 RlckULfQaB4mwkR3SR+//asOH7jfMg914Z5tLl7m5wxGfAQnm2EzVUyOiqC4xj72 iGrYC5oOOY8Ewa8ldz6fCeQFUbxMH/wU+1LbBgaZhmkT62+OJdQxdPqbE0TTrWOP q6Wk+3smstOXuheILsQfNOs61SILBH0bXaL1UprY= Received: (qmail 24066 invoked by alias); 11 Mar 2015 01:15:29 -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 24056 invoked by uid 89); 11 Mar 2015 01:15:28 -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: Wed, 11 Mar 2015 01:15:21 +0000 From: Joseph Myers To: Subject: soft-fp: Add _FP_UNREACHABLE [committed] Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 This patch makes soft-fp use a new macro _FP_UNREACHABLE in place of calling abort in unreachable default cases of switch statements. _FP_UNREACHABLE expands to call __builtin_unreachable for GCC 4.5 and later; the fallback to abort is thus only for kernel use. Tested for powerpc-nofpu that installed stripped shared libraries are unchanged by this patch. Also tested with the math/ tests for mips64 (in the case of fma there *was* previously an abort call generated, unlike for the other operations - one switch only deals with a subset of classes for one operand based on what could have been generated in the earlier part of fma, whereas the other switches deal with all combinations of two classes - and this is apparently too complicated for the default case to have been optimized away). Committed. 2015-03-11 Joseph Myers * soft-fp/soft-fp.h (_FP_UNREACHABLE): New macro. * soft-fp/op-common.h (_FP_MUL): Use _FP_UNREACHABLE instead of abort. (_FP_FMA): Likewise. (_FP_DIV): Likewise. diff --git a/soft-fp/op-common.h b/soft-fp/op-common.h index 0a2f86a..83c2156 100644 --- a/soft-fp/op-common.h +++ b/soft-fp/op-common.h @@ -927,7 +927,7 @@ break; \ \ default: \ - abort (); \ + _FP_UNREACHABLE; \ } \ } \ while (0) @@ -1092,7 +1092,7 @@ break; \ \ default: \ - abort (); \ + _FP_UNREACHABLE; \ } \ \ /* T = X * Y is zero, infinity or NaN. */ \ @@ -1148,7 +1148,7 @@ break; \ \ default: \ - abort (); \ + _FP_UNREACHABLE; \ } \ done_fma: ; \ } \ @@ -1215,7 +1215,7 @@ break; \ \ default: \ - abort (); \ + _FP_UNREACHABLE; \ } \ } \ while (0) diff --git a/soft-fp/soft-fp.h b/soft-fp/soft-fp.h index bb68df9..b247125 100644 --- a/soft-fp/soft-fp.h +++ b/soft-fp/soft-fp.h @@ -51,6 +51,15 @@ # endif #endif +/* For unreachable default cases in switch statements over bitwise OR + of FP_CLS_* values. */ +#if (defined __GNUC__ \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))) +# define _FP_UNREACHABLE __builtin_unreachable () +#else +# define _FP_UNREACHABLE abort () +#endif + /* In the Linux kernel, some architectures have a single function that uses different kinds of unpacking and packing depending on the instruction being emulated, meaning it is not readily visible to