From patchwork Mon Mar 5 11:28:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 144662 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]) by ozlabs.org (Postfix) with SMTP id 71D7AB6EEE for ; Mon, 5 Mar 2012 22:28:55 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1331551738; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=mo727ESnDOu9RMvDXFgA T75IZ2A=; b=raSq4v/r2CTTdxfAUIhn4HjbsJFY/X6Q/naLu2XMX76XvZpcf8rE 0E52Aq1aUfvijsXe1UTVlCkrtrSa4LdWuxFUn0oJCsRlhptowVr8Kpuv3CUIZy48 ParEF+IzPw1uGMxhxKSkQ9wm8hRZDotnN3gDBafeibP1t4biDCd77yk= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=fGw7R6nHzWFfaUiAckYvFd/1WwxT00+ApLBfxdk6mNoSQiTIaiTbiTE2E3awiJ d/+Ga9Q3sgv2S+9k7ZWQ5N6zHmGfFWtYlTWx3A47yOdfuMvlLCVdQGsrtwZ6XzM3 z0DfX6nTF6tGeW2zx2XgUJ7zndO8VrqwHbhYaAKyF24Z4=; Received: (qmail 12564 invoked by alias); 5 Mar 2012 11:28:50 -0000 Received: (qmail 12556 invoked by uid 22791); 5 Mar 2012 11:28:49 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 05 Mar 2012 11:28:34 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id A17F38FE69 for ; Mon, 5 Mar 2012 12:28:33 +0100 (CET) Date: Mon, 5 Mar 2012 12:28:33 +0100 (CET) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Improve trivial foldings with VECTOR_CSTs Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 This handles VECTOR_CSTs in integer_zerop, integer_onep and integer_all_onesp to allow trivial foldings to work on them. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2012-03-05 Richard Guenther * tree.c (integer_zerop): Handle VECTOR_CSTs. (integer_onep): Likewise. (integer_all_onesp): Likewise. Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 184390) +++ gcc/tree.c (working copy) @@ -1714,12 +1714,25 @@ integer_zerop (const_tree expr) { STRIP_NOPS (expr); - return ((TREE_CODE (expr) == INTEGER_CST - && TREE_INT_CST_LOW (expr) == 0 - && TREE_INT_CST_HIGH (expr) == 0) - || (TREE_CODE (expr) == COMPLEX_CST - && integer_zerop (TREE_REALPART (expr)) - && integer_zerop (TREE_IMAGPART (expr)))); + switch (TREE_CODE (expr)) + { + case INTEGER_CST: + return (TREE_INT_CST_LOW (expr) == 0 + && TREE_INT_CST_HIGH (expr) == 0); + case COMPLEX_CST: + return (integer_zerop (TREE_REALPART (expr)) + && integer_zerop (TREE_IMAGPART (expr))); + case VECTOR_CST: + { + tree elt; + for (elt = TREE_VECTOR_CST_ELTS (expr); elt; elt = TREE_CHAIN (elt)) + if (!integer_zerop (TREE_VALUE (elt))) + return false; + return true; + } + default: + return false; + } } /* Return 1 if EXPR is the integer constant one or the corresponding @@ -1730,12 +1743,25 @@ integer_onep (const_tree expr) { STRIP_NOPS (expr); - return ((TREE_CODE (expr) == INTEGER_CST - && TREE_INT_CST_LOW (expr) == 1 - && TREE_INT_CST_HIGH (expr) == 0) - || (TREE_CODE (expr) == COMPLEX_CST - && integer_onep (TREE_REALPART (expr)) - && integer_zerop (TREE_IMAGPART (expr)))); + switch (TREE_CODE (expr)) + { + case INTEGER_CST: + return (TREE_INT_CST_LOW (expr) == 1 + && TREE_INT_CST_HIGH (expr) == 0); + case COMPLEX_CST: + return (integer_onep (TREE_REALPART (expr)) + && integer_zerop (TREE_IMAGPART (expr))); + case VECTOR_CST: + { + tree elt; + for (elt = TREE_VECTOR_CST_ELTS (expr); elt; elt = TREE_CHAIN (elt)) + if (!integer_onep (TREE_VALUE (elt))) + return false; + return true; + } + default: + return false; + } } /* Return 1 if EXPR is an integer containing all 1's in as much precision as @@ -1754,6 +1780,15 @@ integer_all_onesp (const_tree expr) && integer_zerop (TREE_IMAGPART (expr))) return 1; + else if (TREE_CODE (expr) == VECTOR_CST) + { + tree elt; + for (elt = TREE_VECTOR_CST_ELTS (expr); elt; elt = TREE_CHAIN (elt)) + if (!integer_all_onesp (TREE_VALUE (elt))) + return 0; + return 1; + } + else if (TREE_CODE (expr) != INTEGER_CST) return 0;