From patchwork Mon May 6 11:46:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Glisse X-Patchwork-Id: 241622 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 52B6D2C00B6 for ; Mon, 6 May 2013 21:47:04 +1000 (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=NeuCXUcEiWvyVQmH4m7nTYxSQWlEuR4pg3iwuj2Inf4ikCMn4J 1UWPWsTgwVmXez1Hi5u1X4waxU9tNXF5K7H1VJKd7B2l0txT4wucy65Cs2/3t88Y bc4jI6UwVMPQ75TsbfTmf7mFQrfxfV1lDcHHSVAo4T/7aJWlXAYyKRYuA= 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=m9hhBYoUAhwEYifLAL8FPpsEprs=; b=a0mOcY02yAPPyvkALxRa aCwx99kaaM+D7IEVsBGS2gmpKuElP1yuUSueQYS6bpslzRBqm5bJWdW9V8tJDOhZ wfj4SwwA/i9ALWs6/LCdNvpWKWLm3LRK5/QM3Mzxs2ucZ5uZCSvxFeBSfpGK0rM5 6NTcPJE5CXKC9BSsCnk4YsU= Received: (qmail 15383 invoked by alias); 6 May 2013 11:46:57 -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 15372 invoked by uid 89); 6 May 2013 11:46:57 -0000 X-Spam-SWARE-Status: No, score=-5.6 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from mail3-relais-sop.national.inria.fr (HELO mail3-relais-sop.national.inria.fr) (192.134.164.104) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 06 May 2013 11:46:55 +0000 Received: from stedding.saclay.inria.fr ([193.55.250.194]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 06 May 2013 13:46:53 +0200 Received: from glisse (helo=localhost) by stedding.saclay.inria.fr with local-esmtp (Exim 4.80) (envelope-from ) id 1UZJsa-00051M-Ts; Mon, 06 May 2013 13:46:52 +0200 Date: Mon, 6 May 2013 13:46:52 +0200 (CEST) From: Marc Glisse To: gcc-patches@gcc.gnu.org cc: jason@redhat.com Subject: [C++] Missing save_expr in vector-scalar ops Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-Virus-Found: No Hello, this patch is extracted from http://gcc.gnu.org/ml/gcc-patches/2013-04/msg00783.html When I copied this code from the C front-end and removed c_fully_fold, I apparently also removed the save_expr, so I am putting it back in. I added it after convert while the C front-end has it before convert, I can put it before if you prefer. Bootstrap+testsuite on x86_64-linux-gnu. (I believe it should also be backported to 4.8) 2013-05-06 Marc Glisse gcc/cp/ * typeck.c (cp_build_binary_op): Call save_expr before build_vector_from_val. gcc/testsuite/ * c-c++-common/vector-scalar-2.c: New testcase. Index: gcc/testsuite/c-c++-common/vector-scalar-2.c =================================================================== --- gcc/testsuite/c-c++-common/vector-scalar-2.c (revision 0) +++ gcc/testsuite/c-c++-common/vector-scalar-2.c (revision 0) @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +typedef int veci __attribute__ ((vector_size (4 * sizeof (int)))); + +int c; + +void f (veci *a) +{ + *a = *a + ++c; +} + +/* { dg-final { scan-tree-dump-times " \\\+ 1" 1 "gimple" } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */ Property changes on: gcc/testsuite/c-c++-common/vector-scalar-2.c ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision URL Added: svn:eol-style + native Index: gcc/cp/typeck.c =================================================================== --- gcc/cp/typeck.c (revision 198624) +++ gcc/cp/typeck.c (working copy) @@ -3966,29 +3966,31 @@ cp_build_binary_op (location_t location, enum stv_conv convert_flag = scalar_to_vector (location, code, op0, op1, complain & tf_error); switch (convert_flag) { case stv_error: return error_mark_node; case stv_firstarg: { op0 = convert (TREE_TYPE (type1), op0); + op0 = save_expr (op0); op0 = build_vector_from_val (type1, op0); type0 = TREE_TYPE (op0); code0 = TREE_CODE (type0); converted = 1; break; } case stv_secondarg: { op1 = convert (TREE_TYPE (type0), op1); + op1 = save_expr (op1); op1 = build_vector_from_val (type0, op1); type1 = TREE_TYPE (op1); code1 = TREE_CODE (type1); converted = 1; break; } default: break; } }