From patchwork Tue Nov 26 08:07:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 294245 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EAE692C00B1 for ; Tue, 26 Nov 2013 19:08:01 +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 :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=eI8ah5xQeZmxcf3LKN+Hzmi8eO7RWtXeEBE1ztQF0eR eenY7CBASWddmXMG1xn0nhj+0TSH+n+xwkb8v0aSXyzEyRqWkoLZs2mvoQ4gsbk4 8WNr51JBWBHnz8Eulj0xdKK7BYi4fCG4BWvYumqNDmDtyDjKlAXVQrtsarfKcL4c = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=oYXRSsucadBYB+0V0kPq7h10M/E=; b=aqbkEG2kEaRXcOAPg dQzgvfrgsErMz5EXUrN8WQ8f/sfc70i6eAHsH+lW4wHBM6HpQkEy20qG/siIdBal FMq9uelqDJBub9FeLMVoNVmnDp6GU8YHZis7RfJUwaTFwp8izD3ZeJ8tIz3p4dBi sPKa5+TpiT1MUMAokGOqk7/RBI= Received: (qmail 10743 invoked by alias); 26 Nov 2013 08:07:51 -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 10732 invoked by uid 89); 26 Nov 2013 08:07:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Nov 2013 08:07:50 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1VlDgC-0002es-OL from Tom_deVries@mentor.com ; Tue, 26 Nov 2013 00:07:32 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 26 Nov 2013 00:07:32 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Tue, 26 Nov 2013 08:07:30 +0000 Message-ID: <529456C0.8090908@mentor.com> Date: Tue, 26 Nov 2013 09:07:28 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: Jason Merrill CC: , Marc Glisse Subject: [PATCH] Handle vector increment/decrement in build_unary_op Jason, This patch handles vector increment/decrement in build_unary_op and cp_build_binary_op. In other words, we allow v++ and --v on a vector v. v + 1 and v - 1 are already allowed. This fixes an ICE when compiling a vector increment/decrement. Bootstrapped and reg-tested on x86_64. OK for trunk? Thanks, - Tom 2013-11-26 Tom de Vries Marc Glisse PR c++/59032 * c-typeck.c (build_unary_op): Allow vector increment and decrement. * typeck.c (cp_build_unary_op): Allow vector increment and decrement. * g++.dg/pr59032.C: New testcase. * gcc.dg/pr59032.c: Same. diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 0c9c8c8..f602ca4 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -3982,7 +3982,7 @@ build_unary_op (location_t location, if (typecode != POINTER_TYPE && typecode != FIXED_POINT_TYPE && typecode != INTEGER_TYPE && typecode != REAL_TYPE - && typecode != COMPLEX_TYPE) + && typecode != COMPLEX_TYPE && typecode != VECTOR_TYPE) { if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR) error_at (location, "wrong type argument to increment"); @@ -4047,7 +4047,9 @@ build_unary_op (location_t location, } else { - inc = integer_one_node; + inc = VECTOR_TYPE_P (argtype) + ? build_one_cst (argtype) + : integer_one_node; inc = convert (argtype, inc); } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a4da037..9f9f7b6 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5748,7 +5748,9 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, inc = cxx_sizeof_nowarn (TREE_TYPE (argtype)); } else - inc = integer_one_node; + inc = VECTOR_TYPE_P (argtype) + ? build_one_cst (argtype) + : integer_one_node; inc = cp_convert (argtype, inc, complain); diff --git a/gcc/testsuite/g++.dg/pr59032.C b/gcc/testsuite/g++.dg/pr59032.C new file mode 100644 index 0000000..73f8889 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr59032.C @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo() +{ + float v __attribute__((vector_size(8))); + v++; +} + +void +foo2 () +{ + float v __attribute__((vector_size(8))); + ++v; +} + +void +foo3 () +{ + float v __attribute__((vector_size(8))); + v--; +} + +void +foo4 () +{ + float v __attribute__((vector_size(8))); + --v; +} + diff --git a/gcc/testsuite/gcc.dg/pr59032.c b/gcc/testsuite/gcc.dg/pr59032.c new file mode 100644 index 0000000..0d8abc6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr59032.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=gnu99" } */ + +void +foo() +{ + float v __attribute__((vector_size(8))); + v++; +} + +void +foo2 () +{ + float v __attribute__((vector_size(8))); + ++v; +} + +void +foo3 () +{ + float v __attribute__((vector_size(8))); + v--; +} + +void +foo4 () +{ + float v __attribute__((vector_size(8))); + --v; +}