re PR tree-optimization/29964 (function with volatile operators still found to be pure)
2006-11-24 Andrew Pinski <andrew_pinski@playstation.sony.com> PR tree-opt/29964 * ipa-pure-const.c (check_tree): If the original tree is volatile return early and say the function is not pure nor const. Remove the volatile check for writes. (analyze_function): Print out the result of the local analysis pass. 2006-11-24 Andrew Pinski <andrew_pinski@playstation.sony.com> PR tree-opt/29964 * gcc.dg/pure-1.c: New test. From-SVN: r119162
This commit is contained in:
parent
db2675d3c0
commit
13335ae664
4 changed files with 53 additions and 6 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2006-11-24 Andrew Pinski <andrew_pinski@playstation.sony.com>
|
||||||
|
|
||||||
|
PR tree-opt/29964
|
||||||
|
* ipa-pure-const.c (check_tree): If the original tree
|
||||||
|
is volatile return early and say the function is not pure
|
||||||
|
nor const. Remove the volatile check for writes.
|
||||||
|
(analyze_function): Print out the result of the local
|
||||||
|
analysis pass.
|
||||||
|
|
||||||
2006-11-24 Joseph Myers <joseph@codesourcery.com>
|
2006-11-24 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
* config/rs6000/eabispe.h (TARGET_DEFAULT): Include
|
* config/rs6000/eabispe.h (TARGET_DEFAULT): Include
|
||||||
|
|
|
@ -166,6 +166,14 @@ check_tree (funct_state local, tree t, bool checking_write)
|
||||||
if ((TREE_CODE (t) == EXC_PTR_EXPR) || (TREE_CODE (t) == FILTER_EXPR))
|
if ((TREE_CODE (t) == EXC_PTR_EXPR) || (TREE_CODE (t) == FILTER_EXPR))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* Any tree which is volatile disqualifies thie function from being
|
||||||
|
const or pure. */
|
||||||
|
if (TREE_THIS_VOLATILE (t))
|
||||||
|
{
|
||||||
|
local->pure_const_state = IPA_NEITHER;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while (TREE_CODE (t) == REALPART_EXPR
|
while (TREE_CODE (t) == REALPART_EXPR
|
||||||
|| TREE_CODE (t) == IMAGPART_EXPR
|
|| TREE_CODE (t) == IMAGPART_EXPR
|
||||||
|| handled_component_p (t))
|
|| handled_component_p (t))
|
||||||
|
@ -183,12 +191,13 @@ check_tree (funct_state local, tree t, bool checking_write)
|
||||||
|
|
||||||
/* Any indirect reference that occurs on the lhs
|
/* Any indirect reference that occurs on the lhs
|
||||||
disqualifies the function from being pure or const. Any
|
disqualifies the function from being pure or const. Any
|
||||||
indirect reference to a volatile disqualifies the
|
indirect reference that occurs on the rhs disqualifies the
|
||||||
function from being pure or const. Any indirect
|
|
||||||
reference that occurs on the rhs disqualifies the
|
|
||||||
function from being const. */
|
function from being const. */
|
||||||
if (checking_write || TREE_THIS_VOLATILE (t))
|
if (checking_write)
|
||||||
local->pure_const_state = IPA_NEITHER;
|
{
|
||||||
|
local->pure_const_state = IPA_NEITHER;
|
||||||
|
return;
|
||||||
|
}
|
||||||
else if (local->pure_const_state == IPA_CONST)
|
else if (local->pure_const_state == IPA_CONST)
|
||||||
local->pure_const_state = IPA_PURE;
|
local->pure_const_state = IPA_PURE;
|
||||||
}
|
}
|
||||||
|
@ -541,7 +550,7 @@ analyze_function (struct cgraph_node *fn)
|
||||||
walk_tree (bsi_stmt_ptr (bsi), scan_function,
|
walk_tree (bsi_stmt_ptr (bsi), scan_function,
|
||||||
fn, visited_nodes);
|
fn, visited_nodes);
|
||||||
if (l->pure_const_state == IPA_NEITHER)
|
if (l->pure_const_state == IPA_NEITHER)
|
||||||
return;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,6 +577,14 @@ analyze_function (struct cgraph_node *fn)
|
||||||
pop_cfun ();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2006-11-24 Andrew Pinski <andrew_pinski@playstation.sony.com>
|
||||||
|
|
||||||
|
PR tree-opt/29964
|
||||||
|
* gcc.dg/pure-1.c: New test.
|
||||||
|
|
||||||
2006-11-24 Joseph Myers <joseph@codesourcery.com>
|
2006-11-24 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
* g++.dg/eh/simd-2.C: Use -O -w in general for PowerPC.
|
* g++.dg/eh/simd-2.C: Use -O -w in general for PowerPC.
|
||||||
|
|
16
gcc/testsuite/gcc.dg/pure-1.c
Normal file
16
gcc/testsuite/gcc.dg/pure-1.c
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/* Regression test for PR middle-end/23584 */
|
||||||
|
/* Verify that dereferencing a volatile element in a struct causes
|
||||||
|
the function not be pure. */
|
||||||
|
|
||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-O1 -fdump-ipa-pure-const" } */
|
||||||
|
|
||||||
|
struct test_a { volatile int a; };
|
||||||
|
|
||||||
|
int func_a(struct test_a *a)
|
||||||
|
{
|
||||||
|
return a->a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* { dg-final { scan-ipa-dump-not "found to be pure: func_a" "pure-const" } } */
|
||||||
|
/* { dg-final { cleanup-ipa-dump "pure-const" } } */
|
Loading…
Add table
Reference in a new issue