From patchwork Fri Apr 29 12:34:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 616724 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 3qxCnR3gGVz9t3s for ; Fri, 29 Apr 2016 22:34:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=C5FBXP7J; 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; q=dns; s= default; b=EDOhFySV/O1CITeqfY5i5ARnFTNw9NFoVfQ2sVgzfs6hdUVCcl+es 0ZLPYNgoxywnCU1Mzw3ZC3GQL4aqK+SqY4jKXbl/0FVlz9uJW1dS9UFmk6nZfw9R bb/46BJpWkLOFRN2Y/g9lb4Rk6GBDgT36y1fi/kew3wk6fMRnDaZb8= 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; s= default; bh=JCRSFdOaSxGJGWcqhlEEuzkYjiQ=; b=C5FBXP7Jqur6/4/ciBLh eIP2JgzxKGnPS4WtxAJvCbQBtSsZBOot+m3tDC5crFV67PgS0bX1lNgSjYnrvxuK 1YcYfGsmrbI84It3L/1ZUn4EW8kU9IW3I0dbRP7vlIyKmyJJlxJVJL7icO1Pc7Hp x4oH6zexd+7sqZ2znQ/pRSM= Received: (qmail 90115 invoked by alias); 29 Apr 2016 12:34:26 -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 90103 invoked by uid 89); 29 Apr 2016 12:34:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1138, difficulty X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 29 Apr 2016 12:34:21 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BD1D63A for ; Fri, 29 Apr 2016 05:34:22 -0700 (PDT) Received: from localhost (e105548-lin.manchester.arm.com [10.45.32.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2AF723F218 for ; Fri, 29 Apr 2016 05:34:20 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Simplify cst_and_fits_in_hwi Date: Fri, 29 Apr 2016 13:34:18 +0100 Message-ID: <87d1p8fvat.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 While looking at the use of cst_and_fits_in_hwi in tree-ssa-loop-ivopts.c, I had difficulty working out what the function actually tests. The final NUNITS check seems redundant, since it asks about the number of HWIs in the _unextended_ constant. We've already checked that the unextended constant has no more than HOST_BITS_PER_WIDE_INT bits, so the length must be 1. I think this was my fault, sorry. Tested on x86_64-linux-gnu and aarch64-linux-gnu. OK to install? Thanks, Richard gcc/ * tree.c (cst_and_fits_in_hwi): Simplify. Index: gcc/tree.c =================================================================== --- gcc/tree.c +++ gcc/tree.c @@ -1675,13 +1675,8 @@ build_low_bits_mask (tree type, unsigned bits) bool cst_and_fits_in_hwi (const_tree x) { - if (TREE_CODE (x) != INTEGER_CST) - return false; - - if (TYPE_PRECISION (TREE_TYPE (x)) > HOST_BITS_PER_WIDE_INT) - return false; - - return TREE_INT_CST_NUNITS (x) == 1; + return (TREE_CODE (x) == INTEGER_CST + && TYPE_PRECISION (TREE_TYPE (x)) <= HOST_BITS_PER_WIDE_INT); } /* Build a newly constructed VECTOR_CST node of length LEN. */