From patchwork Mon Nov 5 15:10:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 197208 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]) by ozlabs.org (Postfix) with SMTP id 400632C0081 for ; Tue, 6 Nov 2012 02:10:51 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352733053; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Subject:Message-ID:Reply-To: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=rYHcIb1DB0Jx8V1VJhX2 0TZTfF0=; b=mPX66hdbKZVBXF40Vdfs1UfRnbhXSDwKZJoEOkYpKD9zpDEkJMex zusyL5Pydhx91+TaG8sUHyA5Rb7jNRDlTpgh00hI2zakEi1WS/FmLBUJjc+GTC78 bcgAEcKWjo9SN5ELOGOc7nGu7MLGcwSI8qn5TmOeYgSHbBdE6ffMPyc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=dq/SDalrrmGzlVt2K1IiozOKPhixcuwoenNotGcLpxTCgSUHf8x35oGPLa80mv Zj07OSHhOYnJgJP+HSnxKWoN03zmt2qxchWtUnLNWl14PGxR+Iva4lm++QOrZdaB 9gqLUGHMdK3umQn3bHMinOmIVSuxZOAl2qgyTCkt1lyzo=; Received: (qmail 5687 invoked by alias); 5 Nov 2012 15:10:46 -0000 Received: (qmail 5674 invoked by uid 22791); 5 Nov 2012 15:10:45 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_TM X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 05 Nov 2012 15:10:38 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qA5FAcf0013640 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 5 Nov 2012 10:10:38 -0500 Received: from zalov.redhat.com (vpn1-7-9.ams2.redhat.com [10.36.7.9]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qA5FAaiW006608 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 5 Nov 2012 10:10:37 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id qA5FAZJn013739 for ; Mon, 5 Nov 2012 16:10:36 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id qA5FAZEi013738 for gcc-patches@gcc.gnu.org; Mon, 5 Nov 2012 16:10:35 +0100 Date: Mon, 5 Nov 2012 16:10:35 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] 3 backports to 4.7 branch Message-ID: <20121105151035.GM1881@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! I've backported 3 patches of mine to 4.7 branch, and committed them after bootstrap/regtest on x86_64-linux and i686-linux. Jakub 2012-11-05 Jakub Jelinek Backported from mainline 2012-10-10 Jakub Jelinek PR tree-optimization/54877 * tree-vect-loop.c (vect_is_simple_reduction_1): For MINUS_EXPR use make_ssa_name instead of copy_ssa_name. * gcc.dg/torture/pr54877.c: New test. 2012-11-05 Jakub Jelinek Backported from mainline 2012-10-23 Jakub Jelinek PR c++/54988 * decl2.c (cplus_decl_attributes): Don't return early if attributes is NULL. * c-c++-common/pr54988.c: New test. --- gcc/cp/decl2.c (revision 192721) +++ gcc/cp/decl2.c (revision 192722) @@ -1309,8 +1309,7 @@ void cplus_decl_attributes (tree *decl, tree attributes, int flags) { if (*decl == NULL_TREE || *decl == void_type_node - || *decl == error_mark_node - || attributes == NULL_TREE) + || *decl == error_mark_node) return; if (processing_template_decl) @@ -1319,8 +1318,6 @@ cplus_decl_attributes (tree *decl, tree return; save_template_attributes (&attributes, decl); - if (attributes == NULL_TREE) - return; } cp_check_const_attributes (attributes); --- gcc/testsuite/c-c++-common/pr54988.c (revision 0) +++ gcc/testsuite/c-c++-common/pr54988.c (revision 192722) @@ -0,0 +1,20 @@ +/* PR c++/54988 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-msse2" { target { i?86-*-* x86_64-*-* } } } */ + +#if defined(__i386__) || defined(__x86_64__) +#pragma GCC target "fpmath=sse" +#endif + +static inline __attribute__ ((always_inline)) int +foo (int x) +{ + return x; +} + +int +bar (int x) +{ + return foo (x); +} 2012-11-05 Jakub Jelinek Backported from mainline 2012-10-24 Jakub Jelinek PR debug/54828 * gimple.h (is_gimple_sizepos): New inline function. * gimplify.c (gimplify_one_sizepos): Use it. Remove useless final assignment to expr variable. * tree.c (RETURN_TRUE_IF_VAR): Return true also if !TYPE_SIZES_GIMPLIFIED (type) and _t is going to be gimplified into a local temporary. * g++.dg/debug/pr54828.C: New test. --- gcc/tree.c (revision 192758) +++ gcc/tree.c (revision 192759) @@ -8467,14 +8467,19 @@ variably_modified_type_p (tree type, tre tree t; /* Test if T is either variable (if FN is zero) or an expression containing - a variable in FN. */ + a variable in FN. If TYPE isn't gimplified, return true also if + gimplify_one_sizepos would gimplify the expression into a local + variable. */ #define RETURN_TRUE_IF_VAR(T) \ do { tree _t = (T); \ if (_t != NULL_TREE \ && _t != error_mark_node \ && TREE_CODE (_t) != INTEGER_CST \ && TREE_CODE (_t) != PLACEHOLDER_EXPR \ - && (!fn || walk_tree (&_t, find_var_from_fn, fn, NULL))) \ + && (!fn \ + || (!TYPE_SIZES_GIMPLIFIED (type) \ + && !is_gimple_sizepos (_t)) \ + || walk_tree (&_t, find_var_from_fn, fn, NULL))) \ return true; } while (0) if (type == error_mark_node) --- gcc/gimplify.c (revision 192758) +++ gcc/gimplify.c (revision 192759) @@ -7948,9 +7948,7 @@ gimplify_one_sizepos (tree *expr_p, gimp a VAR_DECL. If it's a VAR_DECL from another function, the gimplifier will want to replace it with a new variable, but that will cause problems if this type is from outside the function. It's OK to have that here. */ - if (expr == NULL_TREE || TREE_CONSTANT (expr) - || TREE_CODE (expr) == VAR_DECL - || CONTAINS_PLACEHOLDER_P (expr)) + if (is_gimple_sizepos (expr)) return; type = TREE_TYPE (expr); --- gcc/gimple.h (revision 192758) +++ gcc/gimple.h (revision 192759) @@ -957,6 +957,24 @@ struct gimplify_ctx bool in_cleanup_point_expr; }; +/* Return true if gimplify_one_sizepos doesn't need to gimplify + expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize + fields). */ +static inline bool +is_gimple_sizepos (tree expr) +{ + /* gimplify_one_sizepos doesn't need to do anything if the value isn't there, + is constant, or contains A PLACEHOLDER_EXPR. We also don't want to do + anything if it's already a VAR_DECL. If it's a VAR_DECL from another + function, the gimplifier will want to replace it with a new variable, + but that will cause problems if this type is from outside the function. + It's OK to have that here. */ + return (expr == NULL_TREE + || TREE_CONSTANT (expr) + || TREE_CODE (expr) == VAR_DECL + || CONTAINS_PLACEHOLDER_P (expr)); +} + extern enum gimplify_status gimplify_expr (tree *, gimple_seq *, gimple_seq *, bool (*) (tree), fallback_t); extern void gimplify_type_sizes (tree, gimple_seq *); --- gcc/testsuite/g++.dg/debug/pr54828.C (revision 0) +++ gcc/testsuite/g++.dg/debug/pr54828.C (revision 192759) @@ -0,0 +1,14 @@ +// PR debug/54828 +// { dg-do compile } +// { dg-options "-g" } + +struct T { T (); virtual ~T (); }; +struct S : public virtual T { S (); virtual ~S (); }; +int v; +void foo (char *); + +S::S () +{ + char s[v]; + foo (s); +} --- gcc/tree-vect-loop.c (revision 192321) +++ gcc/tree-vect-loop.c (revision 192322) @@ -2257,7 +2257,10 @@ vect_is_simple_reduction_1 (loop_vec_inf if (orig_code == MINUS_EXPR) { tree rhs = gimple_assign_rhs2 (def_stmt); - tree negrhs = make_ssa_name (SSA_NAME_VAR (rhs), NULL); + tree var = TREE_CODE (rhs) == SSA_NAME + ? SSA_NAME_VAR (rhs) + : create_tmp_reg (TREE_TYPE (rhs), NULL); + tree negrhs = make_ssa_name (var, NULL); gimple negate_stmt = gimple_build_assign_with_ops (NEGATE_EXPR, negrhs, rhs, NULL); gimple_stmt_iterator gsi = gsi_for_stmt (def_stmt); --- gcc/testsuite/gcc.dg/torture/pr54877.c (revision 0) +++ gcc/testsuite/gcc.dg/torture/pr54877.c (revision 192322) @@ -0,0 +1,23 @@ +/* PR tree-optimization/54877 */ +/* { dg-do run } */ +/* { dg-options "-ffast-math" } */ + +extern void abort (void); + +int +foo (void) +{ + double d; + int i; + for (i = 0, d = 0; i < 64; i++) + d--; + return (int) d; +} + +int +main () +{ + if (foo () != -64) + abort (); + return 0; +}