From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51416 invoked by alias); 24 Nov 2015 03:48:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 50223 invoked by uid 89); 24 Nov 2015 03:48:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 24 Nov 2015 03:48:17 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 1410D543C9F; Tue, 24 Nov 2015 04:48:13 +0100 (CET) Date: Tue, 24 Nov 2015 04:02:00 -0000 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: Fix computation of TYPE_CANONICAL of VECTOR_TYPE Message-ID: <20151124034813.GA69066@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-11/txt/msg02817.txt.bz2 Hi, this patch fixes ICE triggered by extra sanity check I added while fixing another type checking ICE during Ada bootstrap. The canonical types of verctor typs are not constructed correctly. If make_vector_type is called with INNERTYPE being a variant (say const char), it builds first the main variant (i.e. vector for char) but when it does canonical type of it, it recurses for vector of TYPE_CANONICAL(const char) instead of TYPE_CANONICAL (char). Se we end up with vector of char while TYPE_CANONICAL is vector of const char With the new sanity check I added to type verifier this now reproduces as several ICEs in the vectorizer testuiste. Bootstrapped/regtested x86_64-linux, OK? * tree.c (make_vector_type): Properly compute canonical type of the main variant. (verify_type): Verify that TYPE_CANONICAl of TYPE_MAIN_VARIANT is a main variant. Index: tree.c =================================================================== --- tree.c (revision 230783) +++ tree.c (working copy) @@ -9843,19 +9844,21 @@ make_vector_type (tree innertype, int nu { tree t; inchash::hash hstate; + tree mv_innertype = TYPE_MAIN_VARIANT (innertype); t = make_node (VECTOR_TYPE); - TREE_TYPE (t) = TYPE_MAIN_VARIANT (innertype); + TREE_TYPE (t) = mv_innertype; SET_TYPE_VECTOR_SUBPARTS (t, nunits); SET_TYPE_MODE (t, mode); - if (TYPE_STRUCTURAL_EQUALITY_P (innertype)) + if (TYPE_STRUCTURAL_EQUALITY_P (mv_innertype)) SET_TYPE_STRUCTURAL_EQUALITY (t); - else if ((TYPE_CANONICAL (innertype) != innertype + else if ((TYPE_CANONICAL (mv_innertype) != mv_innertype || mode != VOIDmode) && !VECTOR_BOOLEAN_TYPE_P (t)) TYPE_CANONICAL (t) - = make_vector_type (TYPE_CANONICAL (innertype), nunits, VOIDmode); + = make_vector_type (TYPE_CANONICAL (mv_innertype), + nunits, VOIDmode); layout_type (t); @@ -13522,6 +13525,13 @@ verify_type (const_tree t) debug_tree (ct); error_found = true; } + if (TYPE_MAIN_VARIANT (t) == t && ct && TYPE_MAIN_VARIANT (ct) != ct) + { + error ("TYPE_CANONICAL of main variant is not main variant"); + debug_tree (ct); + debug_tree (TYPE_MAIN_VARIANT (ct)); + error_found = true; + } /* Check various uses of TYPE_MINVAL. */