On Mon, Mar 10, 2025 at 3:59 PM Martin Jambor <mjam...@suse.cz> wrote:
>
> Hi,
>
> when reading the function ao_compare::compare_ao_refs I came accross
> what I believe to ba a copy-and-paste error which this patch fixes.
>
> Bootstrapped, LTO-bootstrapped and tested on x86_64-linux.  OK for
> master?

By the way here is a testcase which shows what this fixed.
at `-O2 -fno-inline`, ICF now can see both f and g are the same.

```
int c0 = 0;
typedef int v4si __attribute__((vector_size(4*sizeof(int))));
v4si a;
int f()
{
        return a[c0];
}
int g()
{
        return a[c0];
}
```
It was only noticed because of a powerpc testcase failure which was
testing the number of instructions with -fno-inline-functions and
there was failure due to ICF now doing the right thing. See PR 119382.

Thanks,
Andrew


>
> Thanks,
>
> Martin
>
>
> gcc/ChangeLog:
>
> 2025-03-10  Martin Jambor  <mjam...@suse.cz>
>
>         * tree-ssa-alias.cc (ao_compare::compare_ao_refs): Fix a
>         copy-and-paste error.
> ---
>  gcc/tree-ssa-alias.cc | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
> index 2489aa6b808..e93d5187d50 100644
> --- a/gcc/tree-ssa-alias.cc
> +++ b/gcc/tree-ssa-alias.cc
> @@ -4355,12 +4355,13 @@ ao_compare::compare_ao_refs (ao_ref *ref1, ao_ref 
> *ref2,
>         c1 = p1, nskipped1 = i;
>        i++;
>      }
> +  i = 0;
>    for (tree p2 = ref2->ref; handled_component_p (p2); p2 = TREE_OPERAND (p2, 
> 0))
>      {
>        if (component_ref_to_zero_sized_trailing_array_p (p2))
>         end_struct_ref2 = p2;
>        if (ends_tbaa_access_path_p (p2))
> -       c2 = p2, nskipped1 = i;
> +       c2 = p2, nskipped2 = i;
>        i++;
>      }
>
> --
> 2.47.1
>

Reply via email to