From patchwork Wed Jul 25 16:30:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 173211 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 909CA2C0096 for ; Thu, 26 Jul 2012 02:33:19 +1000 (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=1343838799; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:User-Agent:MIME-Version:Message-Id: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=EuSoDih T+7ZHVBVkiBh1gyztf+w=; b=MDh/reI6fscpjB+eXS/GpnN5aFWpOtfQO5GX+3z m0kbLPwFpZg8pPa0eMbe+5bbOuykAf/Jf6wjlF531eAbIqdA+f/YaOxNi4SOOM3K FMS/0+2OdGcLNyD5KNOKGAdLB4qSVgCQ1gbuV/r9bqntrvlzmlH8nWEPFizIe6Bf R18A= 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:From:To:Subject:Date:User-Agent:MIME-Version:Message-Id:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=SHwnIKuEGZ6Ed3orbZPnuaMB00HWn6lci1m2cgBdiH0HRpak6aq3cmcUk3+IEL ItdNxlnGVYikho0qPYDw0xBQESklAejMro83r4yr9Kicc1tzVwidILk/6iZnMqYZ X3fU+aCpQFwXQ0Zz9fvJSLKa+XAunJmQ2tRCC6d7w88dg=; Received: (qmail 11953 invoked by alias); 25 Jul 2012 16:33:08 -0000 Received: (qmail 11931 invoked by uid 22791); 25 Jul 2012 16:33:04 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Jul 2012 16:32:45 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 899F529006F for ; Wed, 25 Jul 2012 18:32:50 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sBy5+dSs0NJv for ; Wed, 25 Jul 2012 18:32:50 +0200 (CEST) Received: from hermes.site (ADijon-552-1-64-234.w92-138.abo.wanadoo.fr [92.138.183.234]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 33A0C29003D for ; Wed, 25 Jul 2012 18:32:50 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Tidy up BIT_FIELD_REF handling code Date: Wed, 25 Jul 2012 18:30:25 +0200 User-Agent: KMail/1.13.5 (Linux/2.6.34.10-0.6-desktop; KDE/4.4.4; x86_64; ; ) MIME-Version: 1.0 Message-Id: <201207251830.25644.ebotcazou@adacore.com> 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 As documented in tree.def and checked in tree-cfg.c, the second and third operands of BIT_FIELD_REF are INTEGER_CSTs so there is no need to do fancy things on them. The patch also removes the now unused build6 stuff and fixes a buglet in the folder. Tested on x86_64-suse-linux, OK for the mainline? 2012-07-25 Eric Botcazou * expr.c (expand_expr_real_1): Do not expand operand #1 and #2 of BIT_FIELD_REF for ignored results. * fold-const.c (fold_ternary_loc) : Check that the CONSTRUCTOR has vector type before using vector accessors on it. * gimplify.c (gimplify_compound_lval): Do not gimplify operand #1 and #2 of BIT_FIELD_REF. (gimplify_expr) : Likewise. * tree-nested.c (convert_nonlocal_reference_op) : Do not process operand #1 and #2. (convert_local_reference_op): Likewise. * tree-ssa-pre.c (create_component_ref_by_pieces_1): Remove superfluous breaks throughout. : Reuse operand #1 and #2 directly. * tree.c (stabilize_reference) : Do not stabilize operand #1 and #2. (UPDATE_FLAGS): Do not consider operand #2 of BIT_FIELD_REF. (build6_stat): Delete. * tree.h (build6_stat, build6, build6_stat_loc, build6_loc): Likewise. ada/ * gcc-interface/utils2.c (gnat_stabilize_reference) : Do not stabilize operand #1 and #2. Index: tree.c =================================================================== --- tree.c (revision 189801) +++ tree.c (working copy) @@ -3526,8 +3526,7 @@ stabilize_reference (tree ref) case BIT_FIELD_REF: result = build_nt (BIT_FIELD_REF, stabilize_reference (TREE_OPERAND (ref, 0)), - stabilize_reference_1 (TREE_OPERAND (ref, 1)), - stabilize_reference_1 (TREE_OPERAND (ref, 2))); + TREE_OPERAND (ref, 1), TREE_OPERAND (ref, 2)); break; case ARRAY_REF: @@ -3697,8 +3696,6 @@ do { tree _node = (NODE); \ if (TREE_OPERAND (node, 2)) UPDATE_FLAGS (TREE_OPERAND (node, 2)); } - else if (TREE_CODE (node) == BIT_FIELD_REF) - UPDATE_FLAGS (TREE_OPERAND (node, 2)); } node = lang_hooks.expr_to_decl (node, &tc, &se); @@ -3969,37 +3966,6 @@ build5_stat (enum tree_code code, tree t return t; } - -tree -build6_stat (enum tree_code code, tree tt, tree arg0, tree arg1, - tree arg2, tree arg3, tree arg4, tree arg5 MEM_STAT_DECL) -{ - bool constant, read_only, side_effects; - tree t; - - gcc_assert (code == TARGET_MEM_REF); - - t = make_node_stat (code PASS_MEM_STAT); - TREE_TYPE (t) = tt; - - side_effects = TREE_SIDE_EFFECTS (t); - - PROCESS_ARG(0); - PROCESS_ARG(1); - PROCESS_ARG(2); - PROCESS_ARG(3); - PROCESS_ARG(4); - if (code == TARGET_MEM_REF) - side_effects = 0; - PROCESS_ARG(5); - - TREE_SIDE_EFFECTS (t) = side_effects; - TREE_THIS_VOLATILE (t) - = (code == TARGET_MEM_REF - && arg5 && TREE_THIS_VOLATILE (arg5)); - - return t; -} /* Build a simple MEM_REF tree with the sematics of a plain INDIRECT_REF on the pointer PTR. */ Index: tree.h =================================================================== --- tree.h (revision 189801) +++ tree.h (working copy) @@ -4245,12 +4245,8 @@ extern tree build4_stat (enum tree_code, extern tree build5_stat (enum tree_code, tree, tree, tree, tree, tree, tree MEM_STAT_DECL); #define build5(c,t1,t2,t3,t4,t5,t6) build5_stat (c,t1,t2,t3,t4,t5,t6 MEM_STAT_INFO) -extern tree build6_stat (enum tree_code, tree, tree, tree, tree, tree, - tree, tree MEM_STAT_DECL); -#define build6(c,t1,t2,t3,t4,t5,t6,t7) \ - build6_stat (c,t1,t2,t3,t4,t5,t6,t7 MEM_STAT_INFO) -/* _loc versions of build[1-6]. */ +/* _loc versions of build[1-5]. */ static inline tree build1_stat_loc (location_t loc, enum tree_code code, tree type, @@ -4311,20 +4307,6 @@ build5_stat_loc (location_t loc, enum tr #define build5_loc(l,c,t1,t2,t3,t4,t5,t6) \ build5_stat_loc (l,c,t1,t2,t3,t4,t5,t6 MEM_STAT_INFO) -static inline tree -build6_stat_loc (location_t loc, enum tree_code code, tree type, tree arg0, - tree arg1, tree arg2, tree arg3, tree arg4, - tree arg5 MEM_STAT_DECL) -{ - tree t = build6_stat (code, type, arg0, arg1, arg2, arg3, arg4, - arg5 PASS_MEM_STAT); - if (CAN_HAVE_LOCATION_P (t)) - SET_EXPR_LOCATION (t, loc); - return t; -} -#define build6_loc(l,c,t1,t2,t3,t4,t5,t6,t7) \ - build6_stat_loc (l,c,t1,t2,t3,t4,t5,t6,t7 MEM_STAT_INFO) - extern tree build_var_debug_value_stat (tree, tree MEM_STAT_DECL); #define build_var_debug_value(t1,t2) \ build_var_debug_value_stat (t1,t2 MEM_STAT_INFO) Index: fold-const.c =================================================================== --- fold-const.c (revision 189801) +++ fold-const.c (working copy) @@ -14043,7 +14043,8 @@ fold_ternary_loc (location_t loc, enum t case BIT_FIELD_REF: if ((TREE_CODE (arg0) == VECTOR_CST - || TREE_CODE (arg0) == CONSTRUCTOR) + || (TREE_CODE (arg0) == CONSTRUCTOR + && TREE_CODE (TREE_TYPE (arg0)) == VECTOR_TYPE)) && (type == TREE_TYPE (TREE_TYPE (arg0)) || (TREE_CODE (type) == VECTOR_TYPE && TREE_TYPE (type) == TREE_TYPE (TREE_TYPE (arg0))))) Index: expr.c =================================================================== --- expr.c (revision 189801) +++ expr.c (working copy) @@ -9111,7 +9111,9 @@ expand_expr_real_1 (tree exp, rtx target } if (TREE_CODE_CLASS (code) == tcc_unary - || code == COMPONENT_REF || code == INDIRECT_REF) + || code == BIT_FIELD_REF + || code == COMPONENT_REF + || code == INDIRECT_REF) return expand_expr (treeop0, const0_rtx, VOIDmode, modifier); @@ -9123,13 +9125,6 @@ expand_expr_real_1 (tree exp, rtx target expand_expr (treeop1, const0_rtx, VOIDmode, modifier); return const0_rtx; } - else if (code == BIT_FIELD_REF) - { - expand_expr (treeop0, const0_rtx, VOIDmode, modifier); - expand_expr (treeop1, const0_rtx, VOIDmode, modifier); - expand_expr (treeop2, const0_rtx, VOIDmode, modifier); - return const0_rtx; - } target = 0; } Index: ada/gcc-interface/utils2.c =================================================================== --- ada/gcc-interface/utils2.c (revision 189801) +++ ada/gcc-interface/utils2.c (working copy) @@ -2644,10 +2644,7 @@ gnat_stabilize_reference (tree ref, bool result = build3 (BIT_FIELD_REF, type, gnat_stabilize_reference (TREE_OPERAND (ref, 0), force, success), - gnat_stabilize_reference_1 (TREE_OPERAND (ref, 1), - force), - gnat_stabilize_reference_1 (TREE_OPERAND (ref, 2), - force)); + TREE_OPERAND (ref, 1), TREE_OPERAND (ref, 2)); break; case ARRAY_REF: Index: gimplify.c =================================================================== --- gimplify.c (revision 189801) +++ gimplify.c (working copy) @@ -2257,7 +2257,7 @@ gimplify_compound_lval (tree *expr_p, gi fallback | fb_lvalue); ret = MIN (ret, tret); - /* And finally, the indices and operands to BIT_FIELD_REF. During this + /* And finally, the indices and operands of ARRAY_REF. During this loop we also remove any useless conversions. */ for (; VEC_length (tree, stack) > 0; ) { @@ -2273,15 +2273,6 @@ gimplify_compound_lval (tree *expr_p, gi ret = MIN (ret, tret); } } - else if (TREE_CODE (t) == BIT_FIELD_REF) - { - tret = gimplify_expr (&TREE_OPERAND (t, 1), pre_p, post_p, - is_gimple_val, fb_rvalue); - ret = MIN (ret, tret); - tret = gimplify_expr (&TREE_OPERAND (t, 2), pre_p, post_p, - is_gimple_val, fb_rvalue); - ret = MIN (ret, tret); - } STRIP_USELESS_TYPE_CONVERSION (TREE_OPERAND (t, 0)); @@ -7406,19 +7397,9 @@ gimplify_expr (tree *expr_p, gimple_seq break; case BIT_FIELD_REF: - { - enum gimplify_status r0, r1, r2; - - r0 = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, - post_p, is_gimple_lvalue, fb_either); - r1 = gimplify_expr (&TREE_OPERAND (*expr_p, 1), pre_p, - post_p, is_gimple_val, fb_rvalue); - r2 = gimplify_expr (&TREE_OPERAND (*expr_p, 2), pre_p, - post_p, is_gimple_val, fb_rvalue); - recalculate_side_effects (*expr_p); - - ret = MIN (r0, MIN (r1, r2)); - } + ret = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, + post_p, is_gimple_lvalue, fb_either); + recalculate_side_effects (*expr_p); break; case TARGET_MEM_REF: Index: tree-ssa-pre.c =================================================================== --- tree-ssa-pre.c (revision 189801) +++ tree-ssa-pre.c (working copy) @@ -2667,7 +2667,7 @@ create_component_ref_by_pieces_1 (basic_ CALL_EXPR_STATIC_CHAIN (folded) = sc; return folded; } - break; + case MEM_REF: { tree baseop = create_component_ref_by_pieces_1 (block, ref, operand, @@ -2690,7 +2690,7 @@ create_component_ref_by_pieces_1 (basic_ } return fold_build2 (MEM_REF, currop->type, baseop, offset); } - break; + case TARGET_MEM_REF: { pre_expr op0expr, op1expr; @@ -2720,7 +2720,7 @@ create_component_ref_by_pieces_1 (basic_ return build5 (TARGET_MEM_REF, currop->type, baseop, currop->op2, genop0, currop->op1, genop1); } - break; + case ADDR_EXPR: if (currop->op0) { @@ -2732,17 +2732,15 @@ create_component_ref_by_pieces_1 (basic_ case IMAGPART_EXPR: case VIEW_CONVERT_EXPR: { - tree folded; tree genop0 = create_component_ref_by_pieces_1 (block, ref, operand, stmts, domstmt); if (!genop0) return NULL_TREE; - folded = fold_build1 (currop->opcode, currop->type, - genop0); - return folded; + + return fold_build1 (currop->opcode, currop->type, genop0); } - break; + case WITH_SIZE_EXPR: { tree genop0 = create_component_ref_by_pieces_1 (block, ref, operand, @@ -2759,28 +2757,18 @@ create_component_ref_by_pieces_1 (basic_ return fold_build2 (currop->opcode, currop->type, genop0, genop1); } - break; + case BIT_FIELD_REF: { - tree folded; tree genop0 = create_component_ref_by_pieces_1 (block, ref, operand, stmts, domstmt); - pre_expr op1expr = get_or_alloc_expr_for (currop->op0); - pre_expr op2expr = get_or_alloc_expr_for (currop->op1); - tree genop1; - tree genop2; + tree op1 = currop->op0; + tree op2 = currop->op1; if (!genop0) return NULL_TREE; - genop1 = find_or_generate_expression (block, op1expr, stmts, domstmt); - if (!genop1) - return NULL_TREE; - genop2 = find_or_generate_expression (block, op2expr, stmts, domstmt); - if (!genop2) - return NULL_TREE; - folded = fold_build3 (BIT_FIELD_REF, currop->type, genop0, genop1, - genop2); - return folded; + + return fold_build3 (BIT_FIELD_REF, currop->type, genop0, op1, op2); } /* For array ref vn_reference_op's, operand 1 of the array ref @@ -2866,10 +2854,9 @@ create_component_ref_by_pieces_1 (basic_ return NULL_TREE; } - return fold_build3 (COMPONENT_REF, TREE_TYPE (op1), op0, op1, - genop2); + return fold_build3 (COMPONENT_REF, TREE_TYPE (op1), op0, op1, genop2); } - break; + case SSA_NAME: { pre_expr op0expr = get_or_alloc_expr_for (currop->op0); Index: tree-nested.c =================================================================== --- tree-nested.c (revision 189801) +++ tree-nested.c (working copy) @@ -1013,13 +1013,6 @@ convert_nonlocal_reference_op (tree *tp, walk_tree (&TREE_OPERAND (t, 3), convert_nonlocal_reference_op, wi, NULL); } - else if (TREE_CODE (t) == BIT_FIELD_REF) - { - walk_tree (&TREE_OPERAND (t, 1), convert_nonlocal_reference_op, - wi, NULL); - walk_tree (&TREE_OPERAND (t, 2), convert_nonlocal_reference_op, - wi, NULL); - } } wi->val_only = false; walk_tree (tp, convert_nonlocal_reference_op, wi, NULL); @@ -1491,13 +1484,6 @@ convert_local_reference_op (tree *tp, in walk_tree (&TREE_OPERAND (t, 3), convert_local_reference_op, wi, NULL); } - else if (TREE_CODE (t) == BIT_FIELD_REF) - { - walk_tree (&TREE_OPERAND (t, 1), convert_local_reference_op, wi, - NULL); - walk_tree (&TREE_OPERAND (t, 2), convert_local_reference_op, wi, - NULL); - } } wi->val_only = false; walk_tree (tp, convert_local_reference_op, wi, NULL);