From patchwork Wed Mar 27 15:38:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 231733 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 2A5D32C00A0 for ; Thu, 28 Mar 2013 02:39:10 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=afmCtEv+r/eh7lYjoQp5ZLXf1LC2KUE3EnpgV3HBY+zMxyK0ON Oovs5MTZEZ85ChGbOlmlPu/eHNBnIuVSCVDL0ZkMEDgEnKoYCQwTKRNNDPX/vhbl jpAklDgo2oeVHh3On7z+hdjQhRTbYf7myfIFi/QNHrBzan17SBbCVVL5I= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=sYHheKMrhumxSBTzU0HW8Mi5AfQ=; b=IE6GbiNBo7AZcUG0pU4L OU+pKEhGYdydas1lHtAaioUK5eF97UZezVGpTkQ/aYPTr/nkPK4elhNGczl+Z5Z7 vxhRpgTiMJYouTbLFqJ89P70v+keRGPloTPDjpF50WYK5eTi3tiOTgRpleQp+E5e pye1s6Y6jRqKY3Sz94Sgjos= Received: (qmail 23763 invoked by alias); 27 Mar 2013 15:38:56 -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 23726 invoked by uid 89); 27 Mar 2013 15:38:49 -0000 X-Spam-SWARE-Status: No, score=-7.1 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 27 Mar 2013 15:38:46 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2RFcjWf005471 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 27 Mar 2013 11:38:45 -0400 Received: from redhat.com (ovpn-116-17.ams2.redhat.com [10.36.116.17]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2RFcf1W010272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 27 Mar 2013 11:38:44 -0400 Date: Wed, 27 Mar 2013 16:38:41 +0100 From: Marek Polacek To: GCC Patches Cc: Richard Biener , Marc Glisse Subject: [PATCH] Fix PR56695 + adjust verify_gimple_comparison Message-ID: <20130327153841.GE9072@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) This fixes PR56695 where we ICEd because expand_vec_cond_expr doesn't expect that the result of a vector comparison is of TYPE_UNSIGNED type. So we unconditionally build a signed type now. We know that the result of vec comparison is e.g. { -1, 0, -1} and that all elements have to be SI types. This patch does one more thing - in verify_gimple_comparison we now explicitly check whether the result of a vec comparison is signed. Regtested/bootstrapped on x86_64-unknown-linux-gnu, ok for trunk? 2013-03-27 Marek Polacek Richard Biener PR tree-optimization/56695 * tree-vect-stmts.c (vectorizable_condition): Unconditionally build signed result of a vector comparison. * tree-cfg.c (verify_gimple_comparison): Check that a result of a vector comparison has signed type. * gcc.dg/vect/pr56695.c: New test. Marek --- gcc/tree-vect-stmts.c.mp 2013-03-27 15:19:43.928738801 +0100 +++ gcc/tree-vect-stmts.c 2013-03-27 15:20:12.485832946 +0100 @@ -5265,7 +5265,7 @@ vectorizable_condition (gimple stmt, gim vec vec_oprnds1 = vNULL; vec vec_oprnds2 = vNULL; vec vec_oprnds3 = vNULL; - tree vec_cmp_type = vectype; + tree vec_cmp_type; if (slp_node || PURE_SLP_STMT (stmt_info)) ncopies = 1; @@ -5338,14 +5338,12 @@ vectorizable_condition (gimple stmt, gim && TREE_CODE (else_clause) != FIXED_CST) return false; - if (!INTEGRAL_TYPE_P (TREE_TYPE (vectype))) - { - unsigned int prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (vectype))); - tree cmp_type = build_nonstandard_integer_type (prec, 1); - vec_cmp_type = get_same_sized_vectype (cmp_type, vectype); - if (vec_cmp_type == NULL_TREE) - return false; - } + unsigned int prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (vectype))); + /* The result of a vector comparison should be signed type. */ + tree cmp_type = build_nonstandard_integer_type (prec, 0); + vec_cmp_type = get_same_sized_vectype (cmp_type, vectype); + if (vec_cmp_type == NULL_TREE) + return false; if (!vec_stmt) { --- gcc/tree-cfg.c.mp 2013-03-27 15:19:59.144788303 +0100 +++ gcc/tree-cfg.c 2013-03-27 15:20:12.475832906 +0100 @@ -3191,7 +3191,10 @@ verify_gimple_comparison (tree type, tre if (TYPE_VECTOR_SUBPARTS (type) != TYPE_VECTOR_SUBPARTS (op0_type) || (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (type))) - != GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op0_type))))) + != GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op0_type)))) + /* The result of a vector comparison is of signed + integral type. */ + || TYPE_UNSIGNED (TREE_TYPE (type))) { error ("invalid vector comparison resulting type"); debug_generic_expr (type); --- gcc/testsuite/gcc.dg/vect/pr56695.c.mp 2013-03-27 15:19:06.901618407 +0100 +++ gcc/testsuite/gcc.dg/vect/pr56695.c 2013-03-27 15:19:00.132596666 +0100 @@ -0,0 +1,14 @@ +/* PR tree-optimization/56695 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize" } */ + +int a, b, i; + +void +f (void) +{ + for (i = 0; i < 8; ++i) + a |= !(i |= b %= 1); +} + +/* { dg-final { cleanup-tree-dump "vect" } } */