From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19840 invoked by alias); 23 Nov 2006 22:49:36 -0000 Received: (qmail 19813 invoked by uid 48); 23 Nov 2006 22:49:28 -0000 Date: Thu, 23 Nov 2006 22:49:00 -0000 Message-ID: <20061123224928.19812.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/29964] [4.1/4.2/4.3 Regression] function with volatile operators still found to be pure In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "pinskia at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-11/txt/msg02064.txt.bz2 ------- Comment #3 from pinskia at gcc dot gnu dot org 2006-11-23 22:49 ------- By the way this is the patch which I am testing: Index: ipa-pure-const.c =================================================================== --- ipa-pure-const.c (revision 119134) +++ ipa-pure-const.c (working copy) @@ -166,6 +166,14 @@ check_tree (funct_state local, tree t, b if ((TREE_CODE (t) == EXC_PTR_EXPR) || (TREE_CODE (t) == FILTER_EXPR)) return; + /* Any tree which is volatile disqualifies this function from being + const or pure. */ + if (TREE_THIS_VOLATILE (t)) + { + local->pure_const_state = IPA_NEITHER; + return; + } + while (TREE_CODE (t) == REALPART_EXPR || TREE_CODE (t) == IMAGPART_EXPR || handled_component_p (t)) @@ -183,12 +191,13 @@ check_tree (funct_state local, tree t, b /* Any indirect reference that occurs on the lhs disqualifies the function from being pure or const. Any - indirect reference to a volatile disqualifies the - function from being pure or const. Any indirect - reference that occurs on the rhs disqualifies the + indirect reference that occurs on the rhs disqualifies the function from being const. */ - if (checking_write || TREE_THIS_VOLATILE (t)) - local->pure_const_state = IPA_NEITHER; + if (checking_write) + { + local->pure_const_state = IPA_NEITHER; + return; + } else if (local->pure_const_state == IPA_CONST) local->pure_const_state = IPA_PURE; } @@ -541,7 +550,7 @@ analyze_function (struct cgraph_node *fn walk_tree (bsi_stmt_ptr (bsi), scan_function, fn, visited_nodes); if (l->pure_const_state == IPA_NEITHER) - return; + goto end; } } @@ -568,6 +577,14 @@ analyze_function (struct cgraph_node *fn pop_cfun (); } } + +end: + if (dump_file) + { + fprintf (dump_file, "after local analysis of %s with initial value = %d\n ", + cgraph_node_name (fn), + l->pure_const_state); + } } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29964