tree-ssa-sccvn.c (visit_phi): Compare invariant addresses as base and offset.
2018-08-01 Richard Biener <rguenther@suse.de> * tree-ssa-sccvn.c (visit_phi): Compare invariant addresses as base and offset. * gcc.dg/tree-ssa/ssa-fre-68.c: New testcase. From-SVN: r263206
This commit is contained in:
parent
42c4ccce72
commit
e4837aa9fb
4 changed files with 56 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2018-08-01 Richard Biener <rguenther@suse.de>
|
||||
|
||||
* tree-ssa-sccvn.c (visit_phi): Compare invariant addresses
|
||||
as base and offset.
|
||||
|
||||
2018-08-01 Martin Liska <mliska@suse.cz>
|
||||
|
||||
* value-prof.c (gimple_divmod_fixed_value_transform): Unify
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2018-08-01 Richard Biener <rguenther@suse.de>
|
||||
|
||||
* gcc.dg/tree-ssa/ssa-fre-68.c: New testcase.
|
||||
|
||||
2018-08-01 Uros Bizjak <ubizjak@gmail.com>
|
||||
|
||||
* gcc.dg/plugin/poly-int-07_plugin.c (dg-options): Use -O0.
|
||||
|
|
28
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-68.c
Normal file
28
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-68.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O -fdump-tree-fre1" } */
|
||||
|
||||
struct S { char a[3]; char b[5]; } s = { "abc", "defg" };
|
||||
|
||||
__SIZE_TYPE__
|
||||
foo (struct S s, int a, int b)
|
||||
{
|
||||
char *p = (char *) &s.a[0];
|
||||
if (a)
|
||||
p = (char *) &s.a;
|
||||
else if (b)
|
||||
p = (char *) &s;
|
||||
return __builtin_strlen (p);
|
||||
}
|
||||
|
||||
__SIZE_TYPE__
|
||||
bar (int a, int b)
|
||||
{
|
||||
char *p = (char *) &s.a[0];
|
||||
if (a)
|
||||
p = (char *) &s.a;
|
||||
else if (b)
|
||||
p = (char *) &s;
|
||||
return __builtin_strlen (p);
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-times "strlen \\\(&s" 2 "fre1" } } */
|
|
@ -3941,6 +3941,8 @@ static bool
|
|||
visit_phi (gimple *phi)
|
||||
{
|
||||
tree result, sameval = VN_TOP, seen_undef = NULL_TREE;
|
||||
tree sameval_base = NULL_TREE;
|
||||
poly_int64 soff, doff;
|
||||
unsigned n_executable = 0;
|
||||
bool allsame = true;
|
||||
edge_iterator ei;
|
||||
|
@ -3971,6 +3973,23 @@ visit_phi (gimple *phi)
|
|||
sameval = def;
|
||||
else if (!expressions_equal_p (def, sameval))
|
||||
{
|
||||
/* We know we're arriving only with invariant addresses here,
|
||||
try harder comparing them. We can do some caching here
|
||||
which we cannot do in expressions_equal_p. */
|
||||
if (TREE_CODE (def) == ADDR_EXPR
|
||||
&& TREE_CODE (sameval) == ADDR_EXPR
|
||||
&& sameval_base != (void *)-1)
|
||||
{
|
||||
if (!sameval_base)
|
||||
sameval_base = get_addr_base_and_unit_offset
|
||||
(TREE_OPERAND (sameval, 0), &soff);
|
||||
if (!sameval_base)
|
||||
sameval_base = (tree)(void *)-1;
|
||||
else if ((get_addr_base_and_unit_offset
|
||||
(TREE_OPERAND (def, 0), &doff) == sameval_base)
|
||||
&& known_eq (soff, doff))
|
||||
continue;
|
||||
}
|
||||
allsame = false;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue