From c4ef2f8634669376c85304a5ebe181edf4f73a4c Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 13 Apr 2015 12:42:41 +0000 Subject: [PATCH] re PR tree-optimization/65204 (Aligned address optimization not detected) 2015-04-13 Richard Biener PR tree-optimization/65204 * tree-ssa-ccp.c (evaluate_stmt): Always evaluate address takens for bit-CCP. * gcc.dg/tree-ssa/ssa-ccp-35.c: New testcase. From-SVN: r222049 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-35.c | 15 +++++++++++++++ gcc/tree-ssa-ccp.c | 4 +++- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-35.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e81d6da9591..641bdffcc8b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-04-13 Richard Biener + + PR tree-optimization/65204 + * tree-ssa-ccp.c (evaluate_stmt): Always evaluate address + takens for bit-CCP. + 2015-04-13 Richard Biener PR target/65660 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5b0cdc34de8..377f5d989fc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-04-13 Richard Biener + + PR tree-optimization/65204 + * gcc.dg/tree-ssa/ssa-ccp-35.c: New testcase. + 2015-04-13 Terry Guo PR target/65710 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-35.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-35.c new file mode 100644 index 00000000000..7cf3a4c844d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-35.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp1" } */ + +typedef char char16[16] __attribute__ ((aligned (16))); +char16 c16[4] __attribute__ ((aligned (4))); + +int f5 (int i) +{ + __SIZE_TYPE__ s = (__SIZE_TYPE__)&c16[i]; + /* 0 */ + return 3 & s; +} + +/* { dg-final { scan-tree-dump "return 0;" "ccp1" } } */ +/* { dg-final { cleanup-tree-dump "ccp1" } } */ diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index d45a3ff2a83..9fbea3a5ca3 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -1748,7 +1748,9 @@ evaluate_stmt (gimple stmt) /* Resort to simplification for bitwise tracking. */ if (flag_tree_bit_ccp - && (likelyvalue == CONSTANT || is_gimple_call (stmt)) + && (likelyvalue == CONSTANT || is_gimple_call (stmt) + || (gimple_assign_single_p (stmt) + && gimple_assign_rhs_code (stmt) == ADDR_EXPR)) && !is_constant) { enum gimple_code code = gimple_code (stmt);