From patchwork Mon Oct 26 10:05:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 535807 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 B56B6140549 for ; Mon, 26 Oct 2015 21:05:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Q46RX2Dy; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=dj4/WMzLyjaKgeKK 1ITpMBVZkGfvG7QyqOn4TKHoRBY9ZleqfrJT8NKyTIE19+bdzp7jr0T2On+q2/U5 InPGVUl9CW9XXuGjptaXSrzmX+0wErcHcD1VXTEwwnsz1sb7xbz0QSgnUNVkDt2u /iZ+zwlpWykmB/sy7Aqv93KrSdw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=fbpJLp4mzIbjfqhfSzfZLX LmiF0=; b=Q46RX2DyceEaL4RsskityPBUx7RvPvlO5eadQ8FrkburwkbO5v/3jZ wTLNaPkJRd2AlV3DMXSqSHt1kFjXa90kNNLSV1HgDxCJAT2odlsiUfKJKXtzwZ76 na8md+Nz5xBOzPNlmfDgbVwsNKgwn336IGfpko7+H/q7k+bl1X8SM= Received: (qmail 100943 invoked by alias); 26 Oct 2015 10:05:14 -0000 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 Received: (qmail 100298 invoked by uid 89); 26 Oct 2015 10:05:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Oct 2015 10:05:12 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-20-oPR-j5ZdQt--mqxOAXZkVA-1; Mon, 26 Oct 2015 10:05:06 +0000 Received: from localhost ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 26 Oct 2015 10:05:04 +0000 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Rename logb and significand folds Date: Mon, 26 Oct 2015 10:05:03 +0000 Message-ID: <87lhaquer4.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: oPR-j5ZdQt--mqxOAXZkVA-1 fold_builtin_logb and fold_builtin_significand now only handle constant arguments, so this patch renames them to fold_const..., to match fold_const_builtin_pow. The idea is to differentiate constant-only folds so that they can be moved to a const_binop-like function in future. The functions also had some unnecessary calls to STRIP_NOPS, which I think are left over from code that has already moved to match.pd. Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. OK to install? Thanks, Richard gcc/ * builtins.c (fold_builtin_logb): Rename to... (fold_const_builtin_logb): ...this and remove STRIP_NOPS call. (fold_builtin_significand): Rename to... (fold_const_builtin_significand): ...this and remove STRIP_NOPS call. (fold_builtin_1): Update accordingly. diff --git a/gcc/builtins.c b/gcc/builtins.c index 86eac5c..260b66d 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -7916,13 +7916,11 @@ fold_builtin_carg (location_t loc, tree arg, tree type) /* Fold a call to builtin logb/ilogb. */ static tree -fold_builtin_logb (location_t loc, tree arg, tree rettype) +fold_const_builtin_logb (location_t loc, tree arg, tree rettype) { if (! validate_arg (arg, REAL_TYPE)) return NULL_TREE; - STRIP_NOPS (arg); - if (TREE_CODE (arg) == REAL_CST && ! TREE_OVERFLOW (arg)) { const REAL_VALUE_TYPE *const value = TREE_REAL_CST_PTR (arg); @@ -7967,13 +7965,11 @@ fold_builtin_logb (location_t loc, tree arg, tree rettype) /* Fold a call to builtin significand, if radix == 2. */ static tree -fold_builtin_significand (location_t loc, tree arg, tree rettype) +fold_const_builtin_significand (location_t loc, tree arg, tree rettype) { if (! validate_arg (arg, REAL_TYPE)) return NULL_TREE; - STRIP_NOPS (arg); - if (TREE_CODE (arg) == REAL_CST && ! TREE_OVERFLOW (arg)) { const REAL_VALUE_TYPE *const value = TREE_REAL_CST_PTR (arg); @@ -9002,11 +8998,11 @@ fold_builtin_1 (location_t loc, tree fndecl, tree arg0) break; CASE_FLT_FN (BUILT_IN_SIGNIFICAND): - return fold_builtin_significand (loc, arg0, type); + return fold_const_builtin_significand (loc, arg0, type); CASE_FLT_FN (BUILT_IN_ILOGB): CASE_FLT_FN (BUILT_IN_LOGB): - return fold_builtin_logb (loc, arg0, type); + return fold_const_builtin_logb (loc, arg0, type); case BUILT_IN_ISASCII: return fold_builtin_isascii (loc, arg0);