On Fri, Oct 02, 2026 at 01:34:31PM +1000, Yongqiang Tian wrote:
> PR tree-optimization/127687
>
> gcc/ChangeLog:
>
> * tree-ssa-forwprop.cc (pass_forwprop::execute): Skip debug
> statements before assigning UIDs.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/pr127687.c: New test.
>
> Signed-off-by: Yongqiang Tian <[email protected]>
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr127687.c
> @@ -0,0 +1,23 @@
> +/* PR tree-optimization/127687 */
> +/* { dg-do compile { target aarch64*-*-* i?86-*-* x86_64-*-* } } */
I don't see any reason to limit the test just to these 3 architectures,
it should compile on any and even be useful there.
No vector argument is passed by value or returned, so there is even no
risk of extra -Wpsabi warnings, and the -fcompare-debug option ensures
on all targets that we don't emit different code based on -g vs. -g0.
> +/* { dg-options "-O2 -fcompare-debug -fdump-tree-forwprop1-details" } */
> +/* { dg-additional-options "-msse2" { target i?86-*-* x86_64-*-* } } */
> +
> +typedef int V __attribute__((vector_size (4 * sizeof (int))));
> +
> +[[gnu::noipa]] void
> +foo (V *x, V *y)
> +{
> + V a = *x;
> + V b = *y;
> + V c = __builtin_shufflevector (a, a, 0, 2, 0, 2);
> + V d = __builtin_shufflevector (a, a, 1, 3, 1, 3);
> + V e = __builtin_shufflevector (b, b, 0, 2, 0, 2);
> + V f = __builtin_shufflevector (b, b, 1, 3, 1, 3);
> + V g = __builtin_shufflevector (c + d, c - d, 0, 4, 1, 5);
> + V h = __builtin_shufflevector (e + f, e - f, 0, 4, 1, 5);
> + *x = g;
> + *y = h;
> +}
> +
> +/* { dg-final { scan-tree-dump "Vec perm simplify sequences have been
> blended" "forwprop1" } } */
I'm not sure this message will be emitted on all, so it is fine to limit
this dg-final to the above mentioned 3 architectures.
> diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
> index f341514a8..fba4387f5 100644
> --- a/gcc/tree-ssa-forwprop.cc
> +++ b/gcc/tree-ssa-forwprop.cc
> @@ -6755,6 +6755,12 @@ pass_forwprop::execute (function *fun)
> tree lhs, rhs;
> enum tree_code code;
>
> + if (is_gimple_debug (stmt))
> + {
> + gsi_next (&gsi);
> + continue;
> + }
> +
This is certainly fine.
Jakub