From 9cd4f22a4519538f2feffa8997ac309d5dcd54b7 Mon Sep 17 00:00:00 2001 From: Peter Bergner Date: Wed, 2 Feb 2011 14:08:06 -0600 Subject: [PATCH] re PR rtl-optimization/47525 (DCE fails to eliminate a dead call to a pure function when compiled with -maltivec) PR rtl-optimization/47525 * df-scan.c: Update copyright years. (df_get_call_refs): Do not mark global registers as DF_REF_REG_USE and non-clobber DF_REF_REG_DEF for calls to const and pure functions. From-SVN: r169768 --- gcc/ChangeLog | 7 +++++++ gcc/df-scan.c | 25 ++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8068d221cc1..d63c0dfa78f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-02-02 Peter Bergner + + PR rtl-optimization/47525 + * df-scan.c: Update copyright years. + (df_get_call_refs): Do not mark global registers as DF_REF_REG_USE + and non-clobber DF_REF_REG_DEF for calls to const and pure functions. + 2011-02-02 Rainer Orth * config/i386/sysv4.h (TARGET_VERSION): Remove. diff --git a/gcc/df-scan.c b/gcc/df-scan.c index 1400d2569b0..42b4b145c02 100644 --- a/gcc/df-scan.c +++ b/gcc/df-scan.c @@ -1,6 +1,6 @@ /* Scanning of rtl for dataflow analysis. Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Originally contributed by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz, mhayes@redhat.com) Major rewrite contributed by Danny Berlin (dberlin@dberlin.org) @@ -3360,16 +3360,19 @@ df_get_call_refs (struct df_collection_rec * collection_rec, NULL, bb, insn_info, DF_REF_REG_USE, DF_REF_CALL_STACK_USAGE | flags); - /* Calls may also reference any of the global registers, - so they are recorded as used. */ - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - if (global_regs[i]) - { - df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i], - NULL, bb, insn_info, DF_REF_REG_USE, flags); - df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i], - NULL, bb, insn_info, DF_REF_REG_DEF, flags); - } + /* Calls to const functions cannot access any global registers and calls to + pure functions cannot set them. All other calls may reference any of the + global registers, so they are recorded as used. */ + if (!RTL_CONST_CALL_P (insn_info->insn)) + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) + if (global_regs[i]) + { + df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i], + NULL, bb, insn_info, DF_REF_REG_USE, flags); + if (!RTL_PURE_CALL_P (insn_info->insn)) + df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i], + NULL, bb, insn_info, DF_REF_REG_DEF, flags); + } is_sibling_call = SIBLING_CALL_P (insn_info->insn); EXECUTE_IF_SET_IN_BITMAP (regs_invalidated_by_call_regset, 0, ui, bi)