From 68ab33a64de503faa184baae68577be517e214b1 Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 4 Apr 2016 09:30:16 +0000 Subject: [PATCH] 2016-04-04 Richard Biener PR rtl-optimization/70484 * rtl.h (canon_output_dependence): Declare. * alias.c (canon_output_dependence): New function. * dse.c (record_store): Use canon_output_dependence rather than canon_true_dependence. * gcc.dg/torture/pr70484.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234709 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 ++++++++ gcc/alias.c | 14 ++++++++++++++ gcc/dse.c | 7 +++---- gcc/rtl.h | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr70484.c | 19 +++++++++++++++++++ 6 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr70484.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 615152586264..83f3454a0eec 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2016-04-04 Richard Biener + + PR rtl-optimization/70484 + * rtl.h (canon_output_dependence): Declare. + * alias.c (canon_output_dependence): New function. + * dse.c (record_store): Use canon_output_dependence rather + than canon_true_dependence. + 2016-03-30 Jan Hubicka PR ipa/68881 diff --git a/gcc/alias.c b/gcc/alias.c index 753e1aff0b16..a0e25dcce06c 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -3057,6 +3057,20 @@ output_dependence (const_rtx mem, const_rtx x) /*mem_canonicalized=*/false, /*x_canonicalized*/false, /*writep=*/true); } + +/* Likewise, but we already have a canonicalized MEM, and X_ADDR for X. + Also, consider X in X_MODE (which might be from an enclosing + STRICT_LOW_PART / ZERO_EXTRACT). + If MEM_CANONICALIZED is true, MEM is canonicalized. */ + +int +canon_output_dependence (const_rtx mem, bool mem_canonicalized, + const_rtx x, machine_mode x_mode, rtx x_addr) +{ + return write_dependence_p (mem, x, x_mode, x_addr, + mem_canonicalized, /*x_canonicalized=*/true, + /*writep=*/true); +} diff --git a/gcc/dse.c b/gcc/dse.c index eef564454aaf..b8da9268d34d 100644 --- a/gcc/dse.c +++ b/gcc/dse.c @@ -1609,10 +1609,9 @@ record_store (rtx body, bb_info_t bb_info) the value of store_info. If it is, set the rhs to NULL to keep it from being used to remove a load. */ { - if (canon_true_dependence (s_info->mem, - GET_MODE (s_info->mem), - s_info->mem_addr, - mem, mem_addr)) + if (canon_output_dependence (s_info->mem, true, + mem, GET_MODE (mem), + mem_addr)) { s_info->rhs = NULL; s_info->const_rhs = NULL; diff --git a/gcc/rtl.h b/gcc/rtl.h index 7f0bfa443a02..79916ad844a2 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3652,6 +3652,8 @@ extern int anti_dependence (const_rtx, const_rtx); extern int canon_anti_dependence (const_rtx, bool, const_rtx, machine_mode, rtx); extern int output_dependence (const_rtx, const_rtx); +extern int canon_output_dependence (const_rtx, bool, + const_rtx, machine_mode, rtx); extern int may_alias_p (const_rtx, const_rtx); extern void init_alias_target (void); extern void init_alias_analysis (void); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a8bd71108278..43bad0faaa21 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-04-04 Richard Biener + + PR rtl-optimization/70484 + * gcc.dg/torture/pr70484.c: New testcase. + 2016-04-04 Marek Polacek PR c/70307 diff --git a/gcc/testsuite/gcc.dg/torture/pr70484.c b/gcc/testsuite/gcc.dg/torture/pr70484.c new file mode 100644 index 000000000000..7604c654fbe5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr70484.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ + +extern void abort (void); + +int __attribute__((noinline,noclone)) +f(int *pi, long *pl) +{ + *pi = 1; + *pl = 0; + return *(char *)pi; +} + +int main() +{ + union { long l; int i; } a; + if (f (&a.i, &a.l) != 0) + abort (); + return 0; +} -- 2.47.3