[fortran] Add support for #pragma GCC unroll v3
Eric Botcazou
ebotcazou@adacore.com
Tue Nov 28 09:59:00 GMT 2017
> The patch looks ok to me.
Thanks.
> For documentation, the gfortran manual has 2 sections:
>
> 6.1 Extensions implemented in GNU Fortran
> 7.2 GNU Fortran Compiler Directives
>
> 6.1 describes extension covering legacy code and vendor extensions.
> 7.2 describes other !$GCC directives. Currently, the section is
> mainly calling conventions (CDECL, STDCALL, etc) and library
> macroc (DLLEXPORT). These should probably be in 7.2.1 and the
> UNROLL directive in 7.2.2.
>
> I can help with the documentation (although it might take a weekend
> or two to get done), but need to know sematics. Does the directive
> apply to only the immediately following loop? Does it apply to all
> loops that follow the directive?
The former. Here's the documentation for the C & C++ compilers:
`#pragma GCC unroll N'
You can use this pragma to control how many times a loop should be
unrolled. It must be placed immediately before a `for', `while'
or `do' loop or a `#pragma GCC ivdep', and applies only to the
loop that follows. N is an integer constant expression specifying
the unrolling factor. The values of 0 and 1 block any unrolling
of the loop.
> What is the interaction of the directive with -funroll-loops and --param
> max-unroll-times=4?
It's independent and always prevails, i.e. it doesn't need -funroll-loops to
be effective, #pragma GCC 0 will block unrolling despite -funroll-loops and
#pragma GCC N wins over --param max-unroll-times=M.
--
Eric Botcazou
More information about the Gcc-patches
mailing list