From 9c44b3951ca82eceb9be44f16a23fbd8c30240f4 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 1 Apr 2010 16:18:07 +0000 Subject: [PATCH] 2010-04-01 Richard Guenther PR middle-end/43614 * tree-ssa-address.c (copy_mem_ref_info): Copy TREE_SIDE_EFFECTS and TREE_THIS_VOLATILE. (copy_ref_info): Likewise. * tree-ssa-operands.c (get_tmr_operands): Check TREE_THIS_VOLATILE. * tree.c (build6_stat): Ignore side-effects of all but arg5 for TARGET_MEM_REF. Set TREE_THIS_VOLATILE from arg5 of TARGET_MEM_REF. * gcc.c-torture/compile/pr43614.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157913 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 11 +++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr43614.c | 27 +++++++++++++++++++++++++++ gcc/tree-ssa-address.c | 2 ++ gcc/tree-ssa-loop-ivopts.c | 6 +++++- gcc/tree-ssa-operands.c | 3 +++ gcc/tree.c | 6 +++++- 7 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr43614.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2e70ef8f246..c2a6a64dfae 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,16 @@ 2010-04-01 Richard Guenther + PR middle-end/43614 + * tree-ssa-address.c (copy_mem_ref_info): Copy TREE_SIDE_EFFECTS + and TREE_THIS_VOLATILE. + (copy_ref_info): Likewise. + * tree-ssa-operands.c (get_tmr_operands): Check TREE_THIS_VOLATILE. + * tree.c (build6_stat): Ignore side-effects of all but arg5 + for TARGET_MEM_REF. Set TREE_THIS_VOLATILE from arg5 of + TARGET_MEM_REF. + +2010-04-01 Richard Guenther + PR tree-optimization/43607 * ipa-type-escape.c (check_call): Do not access non-existing arguments. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 77ebaa66cd5..c182186e61f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-04-01 Richard Guenther + + PR middle-end/43614 + * gcc.c-torture/compile/pr43614.c: New testcase. + 2010-04-01 Martin Jambor PR tree-optimization/43141 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr43614.c b/gcc/testsuite/gcc.c-torture/compile/pr43614.c new file mode 100644 index 00000000000..411b25dac48 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr43614.c @@ -0,0 +1,27 @@ +volatile int g_2[7]; + +void foo (unsigned); + +int main (void) +{ + int i_459 = 0; + int t2818; + int t2819; + volatile char *t2820; + int t2821; + volatile char *t2822; + int *t2823; + unsigned t2824; +LL655: + t2822 = (volatile char *)g_2; + t2821 = i_459; + t2820 = t2822 + t2821; + t2823 = (int *)t2820; + t2824 = *t2823; + foo (t2824); + t2818 = i_459; + t2819 = t2818 + 1; + i_459 = t2819; + goto LL655; +} + diff --git a/gcc/tree-ssa-address.c b/gcc/tree-ssa-address.c index 5cd5d9d29c6..b17257a2a74 100644 --- a/gcc/tree-ssa-address.c +++ b/gcc/tree-ssa-address.c @@ -765,6 +765,8 @@ copy_mem_ref_info (tree to, tree from) { /* And the info about the original reference. */ TMR_ORIGINAL (to) = TMR_ORIGINAL (from); + TREE_SIDE_EFFECTS (to) = TREE_SIDE_EFFECTS (from); + TREE_THIS_VOLATILE (to) = TREE_THIS_VOLATILE (from); } /* Move constants in target_mem_ref REF to offset. Returns the new target diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index e6565dbdf99..f6db2415a36 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -5517,7 +5517,11 @@ copy_ref_info (tree new_ref, tree old_ref) if (TREE_CODE (old_ref) == TARGET_MEM_REF) copy_mem_ref_info (new_ref, old_ref); else - TMR_ORIGINAL (new_ref) = unshare_and_remove_ssa_names (old_ref); + { + TMR_ORIGINAL (new_ref) = unshare_and_remove_ssa_names (old_ref); + TREE_SIDE_EFFECTS (new_ref) = TREE_SIDE_EFFECTS (old_ref); + TREE_THIS_VOLATILE (new_ref) = TREE_THIS_VOLATILE (old_ref); + } } /* Rewrites USE (address that is an iv) using candidate CAND. */ diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c index 9b6d3a325e6..0c525b9da94 100644 --- a/gcc/tree-ssa-operands.c +++ b/gcc/tree-ssa-operands.c @@ -732,6 +732,9 @@ get_indirect_ref_operands (gimple stmt, tree expr, int flags, static void get_tmr_operands (gimple stmt, tree expr, int flags) { + if (TREE_THIS_VOLATILE (expr)) + gimple_set_has_volatile_ops (stmt, true); + /* First record the real operands. */ get_expr_operands (stmt, &TMR_BASE (expr), opf_use | (flags & opf_no_vops)); get_expr_operands (stmt, &TMR_INDEX (expr), opf_use | (flags & opf_no_vops)); diff --git a/gcc/tree.c b/gcc/tree.c index 86fe2bb3b62..863b51eda94 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -3824,10 +3824,14 @@ build6_stat (enum tree_code code, tree tt, tree arg0, tree arg1, 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) = 0; + TREE_THIS_VOLATILE (t) + = (code == TARGET_MEM_REF + && arg5 && TREE_THIS_VOLATILE (arg5)); return t; } -- 2.11.0