On Thu, Sep 10, 2026 at 1:19 AM Richard Biener <[email protected]> wrote:
>
> The following makes the GIMPLE parser handle
>
> ... ={v} ...
>
> which is how we dump gimple_has_volatile_ops which is a flag
> that caches information that's available by other means as it
> is computed by the operand scanner. It's not necessary for
> parsing, so instead of parsing and ignoring it we could omit
> it from -gimple dumps, but it does provide visual information
> to the reader.
>
> This allows more -gimple dumps to be consumed by the GIMPLE
> frontend without editing.
>
> Bootstrap and regtest in progress on x86_64-unknown-linux-gnu.
>
> Any comments?
I like it. Definitely it is useful. Especially with your next patch
to handle clobbers.
>
> Thanks,
> Richard.
>
> gcc/c/
> * gimple-parser.cc (c_parser_gimple_statement): Parse
> but ignore {v} marker on assignments.
> ---
> gcc/c/gimple-parser.cc | 16 ++++++++++++++++
> gcc/testsuite/gcc.dg/gimplefe-61.c | 9 +++++++++
> 2 files changed, 25 insertions(+)
> create mode 100644 gcc/testsuite/gcc.dg/gimplefe-61.c
>
> diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc
> index 7d374dd66b0..0e0c8ba673b 100644
> --- a/gcc/c/gimple-parser.cc
> +++ b/gcc/c/gimple-parser.cc
> @@ -806,6 +806,22 @@ c_parser_gimple_statement (gimple_parser &parser,
> gimple_seq *seq)
> if (! c_parser_require (parser, CPP_EQ, "expected %<=%>"))
> return;
>
> + /* Eat and ignore {v} right after the =, the has_volatile_ops is
> + redundant and re-computed by the operand scanner. */
> + if (c_parser_next_token_is (parser, CPP_OPEN_BRACE)
> + && !(c_parser_peek_token (parser)->flags & PREV_WHITE)
> + && c_parser_peek_2nd_token (parser)->type == CPP_NAME
> + && !(c_parser_peek_2nd_token (parser)->flags & PREV_WHITE)
> + && strcmp ("v", IDENTIFIER_POINTER
> + (c_parser_peek_2nd_token (parser)->value)) == 0
> + && c_parser_peek_nth_token (parser, 3)->type == CPP_CLOSE_BRACE
> + && !(c_parser_peek_nth_token (parser, 3)->flags & PREV_WHITE))
> + {
> + c_parser_consume_token (parser);
> + c_parser_consume_token (parser);
> + c_parser_consume_token (parser);
> + }
> +
> /* Cast expression. */
> if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
> && c_token_starts_typename (c_parser_peek_2nd_token (parser)))
> diff --git a/gcc/testsuite/gcc.dg/gimplefe-61.c
> b/gcc/testsuite/gcc.dg/gimplefe-61.c
> new file mode 100644
> index 00000000000..ec11ee9bcee
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/gimplefe-61.c
> @@ -0,0 +1,9 @@
> +/* { dg-do compile } */
> +/* { dg-options "-fgimple" } */
> +
> +volatile int i;
> +
> +void __GIMPLE foo ()
> +{
> + i ={v} 1;
> +}
> --
> 2.51.0