From patchwork Mon Mar 21 10:16:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 600041 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 3qTBbD3F0Kz9s4n for ; Mon, 21 Mar 2016 21:17:27 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=uuXOOZ//; 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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=GB7v4/uUxrzDJ1kaR9PmJyKKwcXLV8qCimQ8kYP8zp2uLCF8NfoLf kM9s/TSD+X3qipuPFKTT4I0gxufFqggU6QV8syNzYpgQ7IZFudl7SZlwBRqWWlVg NHsOD6GgLGoAl803KUQ8pCwe3Vp2b451AUz2c02mHVTw4bBrq/2PeY= 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:subject:message-id:mime-version:content-type; s= default; bh=W+5xKYzz5wz0STW0Av/cK2DCoHo=; b=uuXOOZ//Uz0zcD8jTtXR YRBbW+hSbptFdZaCVDHFUzkYnkifSP+5RbuxfYkmMxR1q0HkRhrZmT2KO8VkDeFR I0bOmsQ0+Q9CD3vKlXVdlBJBBnKAWCBAEswzpJVNH01t0S0e5pBDHfcO53+vfVaS dMCFWGyX09y5WqdNCtmYLq8= Received: (qmail 25860 invoked by alias); 21 Mar 2016 10:17:00 -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 25759 invoked by uid 89); 21 Mar 2016 10:16:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=dg-do, dgdo X-HELO: mail-io0-f169.google.com Received: from mail-io0-f169.google.com (HELO mail-io0-f169.google.com) (209.85.223.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 21 Mar 2016 10:16:56 +0000 Received: by mail-io0-f169.google.com with SMTP id 124so51900249iov.3 for ; Mon, 21 Mar 2016 03:16:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=5bfGsPUHy2D6tZL6cFdlae27xXykScFFynfJ+hRFR7M=; b=DGGP0e9Dt4dYTGI4MNSeealXGwpL14AKpvbEilaMaTW66JVTVXvbCJfd/1gnqUYTSM vFaorTZdRkKNp61iWtNpEg39IK708D42Tw+FALby/U2bziYB1StRSBnD9rN3yddW/7mk h1prexHnR9ibuz1IfHK3Fx3Ol8ASzTXRsQ64mD4p+7PWEn+YMhfwS9Z2mwHhotNPLw6f FmVIQaNQppHk66CTXQVYyDxDO5aw1ADbSxXTz6pj05CR/67U3Mgrhnyl1N6CmirJ2Y2X isYt6xNfJNWk5CqGeh3wfEw8oa5E0PHKFO20DWgyjQsNt0Q0kKOfgDq2gKenRVx85MwC XxPg== X-Gm-Message-State: AD7BkJLamD2uthtUGLX54/AXcb+y2ZAKdNdjwrNr1eRPcol3uKTrjYWSYAYJwSVFXLK3jg== X-Received: by 10.107.38.82 with SMTP id m79mr26607587iom.2.1458555414544; Mon, 21 Mar 2016 03:16:54 -0700 (PDT) Received: from msticlxl57.ims.intel.com (irdmzpr01-ext.ir.intel.com. [192.198.151.36]) by smtp.gmail.com with ESMTPSA id i74sm11080072ioe.37.2016.03.21.03.16.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Mar 2016 03:16:54 -0700 (PDT) Date: Mon, 21 Mar 2016 13:16:01 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, C++, PR70290] Fix type checks for vector conditional expr Message-ID: <20160321101601.GA23287@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi, This patch makes an integer vector type to always be used for type checks when building a vector conditional expression. With no this patch we may get a type of vector comparison which may have non-vector mode and different size in case of scalar masks usage. Bootstrapped and regetsted on x86_64-pc-linux-gnu. OK for trunk? Thanks, Ilya --- gcc/cp/ 2016-03-21 Ilya Enkovich * call.c (build_conditional_expr_1): Always use original condition type for vector type checks and build. gcc/testsuite/ 2016-03-21 Ilya Enkovich * g++.dg/ext/pr70290.C: New test. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 1edbce8..d3a256c 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4634,6 +4634,8 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, if (VECTOR_INTEGER_TYPE_P (TREE_TYPE (arg1))) { + tree arg1_type = TREE_TYPE (arg1); + /* If arg1 is another cond_expr choosing between -1 and 0, then we can use its comparison. It may help to avoid additional comparison, produce more accurate diagnostics @@ -4653,7 +4655,6 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, || error_operand_p (arg3)) return error_mark_node; - tree arg1_type = TREE_TYPE (arg1); arg2_type = TREE_TYPE (arg2); arg3_type = TREE_TYPE (arg3); diff --git a/gcc/testsuite/g++.dg/ext/pr70290.C b/gcc/testsuite/g++.dg/ext/pr70290.C new file mode 100644 index 0000000..6de13ce --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pr70290.C @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-mavx512vl" { target { i?86-*-* x86_64-*-* } } } */ + +typedef int vec __attribute__((vector_size(32))); + +vec +test1 (vec x,vec y) +{ + return (x < y) ? 1 : 0; +} + +vec +test2 (vec x,vec y) +{ + vec zero = { }; + vec one = zero + 1; + return (x < y) ? one : zero; +}