[PATCH 4/5] lto: Set has_unroll flag when streaming in for LTO [PR116140]
Richard Biener
richard.guenther@gmail.com
Fri Aug 9 11:12:22 GMT 2024
> Am 09.08.2024 um 11:30 schrieb Alex Coplan <alex.coplan@arm.com>:
>
> When #pragma GCC unroll is processed in
> tree-cfg.cc:replace_loop_annotate_in_block, we set both the loop->unroll
> field (which is currently streamed out and back in during LTO) but also
> the cfun->has_unroll flag.
>
> cfun->has_unroll, however, is not currently streamed during LTO, so this
> patch attempts to recover it by setting it on any function containing a
> loop with loop->unroll > 1.
>
> Prior to this patch, loops marked with #pragma GCC unroll that would be
> unrolled by RTL loop2_unroll in a non-LTO compilation didn't get
> unrolled under LTO.
>
> As per the comment in the PR, a more conservative fix might explicitly
> stream out cfun->has_unroll and stream it back in again, but this patch
> it simpler and I can't currently see a reason against inferring the
> value of the flag like this (comments welcome).
If the flag is redundant please eliminate it entirely. Otherwise please stream it.
> gcc/ChangeLog:
>
> PR libstdc++/116140
> * lto-streamer-in.cc (input_cfg): Set fn->has_unroll if fn
> contains a loop with requested unrolling.
>
> gcc/testsuite/ChangeLog:
>
> PR libstdc++/116140
> * g++.dg/ext/pragma-unroll-lambda-lto.C: New test.
> ---
> gcc/lto-streamer-in.cc | 2 ++
> .../g++.dg/ext/pragma-unroll-lambda-lto.C | 32 +++++++++++++++++++
> 2 files changed, 34 insertions(+)
> create mode 100644 gcc/testsuite/g++.dg/ext/pragma-unroll-lambda-lto.C
>
> <0004-lto-Set-has_unroll-flag-when-streaming-in-for-LTO-PR.patch>
More information about the Gcc-patches
mailing list