]>
Commit | Line | Data |
---|---|---|
c63539ff ML |
1 | .. |
2 | Copyright 1988-2022 Free Software Foundation, Inc. | |
3 | This is part of the GCC manual. | |
4 | For copying conditions, see the copyright.rst file. | |
5 | ||
6 | .. index:: code generation, conventions, options, code generation, options, run-time | |
7 | ||
8 | .. _code-gen-options: | |
9 | ||
10 | Options for code generation conventions | |
11 | *************************************** | |
12 | ||
13 | These machine-independent options control the interface conventions | |
14 | used in code generation. | |
15 | ||
16 | Most of them have both positive and negative forms; the negative form | |
17 | of :samp:`-ffoo` would be :samp:`-fno-foo`. In the table below, only | |
18 | one of the forms is listed---the one which is not the default. You | |
19 | can figure out the other form by either removing no- or adding | |
20 | it. | |
21 | ||
22 | .. index:: fno-automatic, SAVE statement, statement, SAVE | |
23 | ||
24 | .. option:: -fno-automatic | |
25 | ||
26 | Treat each program unit (except those marked as RECURSIVE) as if the | |
27 | ``SAVE`` statement were specified for every local variable and array | |
28 | referenced in it. Does not affect common blocks. (Some Fortran compilers | |
29 | provide this option under the name :option:`-static` or :option:`-save`.) | |
30 | The default, which is :option:`-fautomatic`, uses the stack for local | |
31 | variables smaller than the value given by :option:`-fmax-stack-var-size`. | |
32 | Use the option :option:`-frecursive` to use no static memory. | |
33 | ||
34 | Local variables or arrays having an explicit ``SAVE`` attribute are | |
35 | silently ignored unless the :option:`-pedantic` option is added. | |
36 | ||
37 | .. index:: calling convention, f2c calling convention, g77 calling convention, libf2c calling convention | |
38 | ||
39 | .. option:: -ff2c | |
40 | ||
41 | Generate code designed to be compatible with code generated | |
42 | by :command:`g77` and :command:`f2c`. | |
43 | ||
44 | The calling conventions used by :command:`g77` (originally implemented | |
45 | in :command:`f2c`) require functions that return type | |
46 | default ``REAL`` to actually return the C type ``double``, and | |
47 | functions that return type ``COMPLEX`` to return the values via an | |
48 | extra argument in the calling sequence that points to where to | |
49 | store the return value. Under the default GNU calling conventions, such | |
50 | functions simply return their results as they would in GNU | |
51 | C---default ``REAL`` functions return the C type ``float``, and | |
52 | ``COMPLEX`` functions return the GNU C type ``complex``. | |
53 | Additionally, this option implies the :option:`-fsecond-underscore` | |
54 | option, unless :option:`-fno-second-underscore` is explicitly requested. | |
55 | ||
56 | This does not affect the generation of code that interfaces with | |
57 | the :command:`libgfortran` library. | |
58 | ||
59 | .. warning:: | |
60 | ||
61 | It is not a good idea to mix Fortran code compiled with | |
62 | :option:`-ff2c` with code compiled with the default :option:`-fno-f2c` | |
63 | calling conventions as, calling ``COMPLEX`` or default ``REAL`` | |
64 | functions between program parts which were compiled with different | |
65 | calling conventions will break at execution time. | |
66 | ||
67 | .. warning:: | |
68 | ||
69 | This will break code which passes intrinsic functions | |
70 | of type default ``REAL`` or ``COMPLEX`` as actual arguments, as | |
71 | the library implementations use the :option:`-fno-f2c` calling conventions. | |
72 | ||
73 | .. index:: fno-underscoring, underscore, symbol names, underscores, transforming symbol names, symbol names, transforming | |
74 | ||
75 | .. option:: -fno-underscoring | |
76 | ||
77 | Do not transform names of entities specified in the Fortran | |
78 | source file by appending underscores to them. | |
79 | ||
80 | With :option:`-funderscoring` in effect, GNU Fortran appends one | |
81 | underscore to external names with no underscores. This is done to ensure | |
82 | compatibility with code produced by many UNIX Fortran compilers. | |
83 | ||
84 | .. warning:: | |
85 | ||
86 | The default behavior of GNU Fortran is | |
87 | incompatible with :command:`f2c` and :command:`g77`, please use the | |
88 | :option:`-ff2c` option if you want object files compiled with | |
89 | GNU Fortran to be compatible with object code created with these | |
90 | tools. | |
91 | ||
92 | Use of :option:`-fno-underscoring` is not recommended unless you are | |
93 | experimenting with issues such as integration of GNU Fortran into | |
94 | existing system environments (vis-ā-vis existing libraries, tools, | |
95 | and so on). | |
96 | ||
97 | For example, with :option:`-funderscoring`, and assuming that ``j()`` and | |
98 | ``max_count()`` are external functions while ``my_var`` and | |
99 | ``lvar`` are local variables, a statement like | |
100 | ||
101 | .. code-block:: fortran | |
102 | ||
103 | I = J() + MAX_COUNT (MY_VAR, LVAR) | |
104 | ||
105 | is implemented as something akin to: | |
106 | ||
107 | .. code-block:: fortran | |
108 | ||
109 | i = j_() + max_count__(&my_var__, &lvar); | |
110 | ||
111 | With :option:`-fno-underscoring`, the same statement is implemented as: | |
112 | ||
113 | .. code-block:: fortran | |
114 | ||
115 | i = j() + max_count(&my_var, &lvar); | |
116 | ||
117 | Use of :option:`-fno-underscoring` allows direct specification of | |
118 | user-defined names while debugging and when interfacing GNU Fortran | |
119 | code with other languages. | |
120 | ||
121 | Note that just because the names match does *not* mean that the | |
122 | interface implemented by GNU Fortran for an external name matches the | |
123 | interface implemented by some other language for that same name. | |
124 | That is, getting code produced by GNU Fortran to link to code produced | |
125 | by some other compiler using this or any other method can be only a | |
126 | small part of the overall solution---getting the code generated by | |
127 | both compilers to agree on issues other than naming can require | |
128 | significant effort, and, unlike naming disagreements, linkers normally | |
129 | cannot detect disagreements in these other areas. | |
130 | ||
131 | Also, note that with :option:`-fno-underscoring`, the lack of appended | |
132 | underscores introduces the very real possibility that a user-defined | |
133 | external name will conflict with a name in a system library, which | |
134 | could make finding unresolved-reference bugs quite difficult in some | |
135 | cases---they might occur at program run time, and show up only as | |
136 | buggy behavior at run time. | |
137 | ||
138 | In future versions of GNU Fortran we hope to improve naming and linking | |
139 | issues so that debugging always involves using the names as they appear | |
140 | in the source, even if the names as seen by the linker are mangled to | |
141 | prevent accidental linking between procedures with incompatible | |
142 | interfaces. | |
143 | ||
144 | .. index:: fsecond-underscore, underscore, symbol names, underscores, transforming symbol names, symbol names, transforming, f2c calling convention, g77 calling convention, libf2c calling convention | |
145 | ||
146 | .. option:: -fsecond-underscore | |
147 | ||
148 | By default, GNU Fortran appends an underscore to external | |
149 | names. If this option is used GNU Fortran appends two | |
150 | underscores to names with underscores and one underscore to external names | |
151 | with no underscores. GNU Fortran also appends two underscores to | |
152 | internal names with underscores to avoid naming collisions with external | |
153 | names. | |
154 | ||
155 | This option has no effect if :option:`-fno-underscoring` is | |
156 | in effect. It is implied by the :option:`-ff2c` option. | |
157 | ||
158 | Otherwise, with this option, an external name such as ``MAX_COUNT`` | |
159 | is implemented as a reference to the link-time external symbol | |
160 | ``max_count__``, instead of ``max_count_``. This is required | |
161 | for compatibility with :command:`g77` and :command:`f2c`, and is implied | |
162 | by use of the :option:`-ff2c` option. | |
163 | ||
164 | .. index:: fcoarray, coarrays | |
165 | ||
166 | .. option:: -fcoarray={<keyword>} | |
167 | ||
168 | none | |
169 | Disable coarray support; using coarray declarations and image-control | |
170 | statements will produce a compile-time error. (Default) | |
171 | ||
172 | single | |
173 | Single-image mode, i.e. ``num_images()`` is always one. | |
174 | ||
175 | lib | |
176 | Library-based coarray parallelization; a suitable GNU Fortran coarray | |
177 | library needs to be linked. | |
178 | ||
179 | .. index:: fcheck, array, bounds checking, bit intrinsics checking, bounds checking, pointer checking, memory checking, range checking, subscript checking, checking subscripts, run-time checking, checking array temporaries | |
180 | ||
181 | .. option:: -fcheck={<keyword>} | |
182 | ||
183 | Enable the generation of run-time checks; the argument shall be | |
184 | a comma-delimited list of the following keywords. Prefixing a check with | |
185 | no- disables it if it was activated by a previous specification. | |
186 | ||
187 | all | |
188 | Enable all run-time test of :option:`-fcheck`. | |
189 | ||
190 | array-temps | |
191 | Warns at run time when for passing an actual argument a temporary array | |
192 | had to be generated. The information generated by this warning is | |
193 | sometimes useful in optimization, in order to avoid such temporaries. | |
194 | ||
195 | Note: The warning is only printed once per location. | |
196 | ||
197 | bits | |
198 | Enable generation of run-time checks for invalid arguments to the bit | |
199 | manipulation intrinsics. | |
200 | ||
201 | bounds | |
202 | Enable generation of run-time checks for array subscripts | |
203 | and against the declared minimum and maximum values. It also | |
204 | checks array indices for assumed and deferred | |
205 | shape arrays against the actual allocated bounds and ensures that all string | |
206 | lengths are equal for character array constructors without an explicit | |
207 | typespec. | |
208 | ||
209 | Some checks require that :option:`-fcheck=bounds` is set for | |
210 | the compilation of the main program. | |
211 | ||
212 | Note: In the future this may also include other forms of checking, e.g., | |
213 | checking substring references. | |
214 | ||
215 | do | |
216 | Enable generation of run-time checks for invalid modification of loop | |
217 | iteration variables. | |
218 | ||
219 | mem | |
220 | Enable generation of run-time checks for memory allocation. | |
221 | Note: This option does not affect explicit allocations using the | |
222 | ``ALLOCATE`` statement, which will be always checked. | |
223 | ||
224 | pointer | |
225 | Enable generation of run-time checks for pointers and allocatables. | |
226 | ||
227 | recursion | |
228 | Enable generation of run-time checks for recursively called subroutines and | |
229 | functions which are not marked as recursive. See also :option:`-frecursive`. | |
230 | Note: This check does not work for OpenMP programs and is disabled if used | |
231 | together with :option:`-frecursive` and :option:`-fopenmp`. | |
232 | ||
233 | Example: Assuming you have a file :samp:`foo.f90`, the command | |
234 | ||
235 | .. code-block:: bash | |
236 | ||
237 | gfortran -fcheck=all,no-array-temps foo.f90 | |
238 | ||
239 | will compile the file with all checks enabled as specified above except | |
240 | warnings for generated array temporaries. | |
241 | ||
242 | .. index:: fbounds-check | |
243 | ||
244 | .. option:: -fbounds-check | |
245 | ||
246 | .. Note: This option is also referred in gcc's manpage | |
247 | ||
248 | Deprecated alias for :option:`-fcheck=bounds`. | |
249 | ||
250 | .. index:: tail-call-workaround | |
251 | ||
252 | .. option:: -ftail-call-workaround, -ftail-call-workaround={n} | |
253 | ||
254 | Some C interfaces to Fortran codes violate the gfortran ABI by | |
255 | omitting the hidden character length arguments as described in | |
256 | See :ref:`argument-passing-conventions`. This can lead to crashes | |
257 | because pushing arguments for tail calls can overflow the stack. | |
258 | ||
259 | To provide a workaround for existing binary packages, this option | |
260 | disables tail call optimization for gfortran procedures with character | |
261 | arguments. With :option:`-ftail-call-workaround=2` tail call optimization | |
262 | is disabled in all gfortran procedures with character arguments, | |
263 | with :option:`-ftail-call-workaround=1` or equivalent | |
264 | :option:`-ftail-call-workaround` only in gfortran procedures with character | |
265 | arguments that call implicitly prototyped procedures. | |
266 | ||
267 | Using this option can lead to problems including crashes due to | |
268 | insufficient stack space. | |
269 | ||
270 | It is *very strongly* recommended to fix the code in question. | |
271 | The :option:`-fc-prototypes-external` option can be used to generate | |
272 | prototypes which conform to gfortran's ABI, for inclusion in the | |
273 | source code. | |
274 | ||
275 | Support for this option will likely be withdrawn in a future release | |
276 | of gfortran. | |
277 | ||
278 | The negative form, :option:`-fno-tail-call-workaround` or equivalent | |
279 | :option:`-ftail-call-workaround=0`, can be used to disable this option. | |
280 | ||
281 | Default is currently :option:`-ftail-call-workaround`, this will change | |
282 | in future releases. | |
283 | ||
284 | .. index:: fcheck-array-temporaries | |
285 | ||
286 | .. option:: -fcheck-array-temporaries | |
287 | ||
288 | Deprecated alias for :option:`-fcheck=array-temps`. | |
289 | ||
290 | .. index:: fmax-array-constructor | |
291 | ||
292 | .. option:: -fmax-array-constructor={n} | |
293 | ||
294 | This option can be used to increase the upper limit permitted in | |
295 | array constructors. The code below requires this option to expand | |
296 | the array at compile time. | |
297 | ||
298 | .. code-block:: fortran | |
299 | ||
300 | program test | |
301 | implicit none | |
302 | integer j | |
303 | integer, parameter :: n = 100000 | |
304 | integer, parameter :: i(n) = (/ (2*j, j = 1, n) /) | |
305 | print '(10(I0,1X))', i | |
306 | end program test | |
307 | ||
308 | .. warning:: | |
309 | This option can lead to long compile times and excessively | |
310 | large object files. | |
311 | ||
312 | The default value for :samp:`{n}` is 65535. | |
313 | ||
314 | .. index:: fmax-stack-var-size | |
315 | ||
316 | .. option:: -fmax-stack-var-size={n} | |
317 | ||
318 | This option specifies the size in bytes of the largest array that will be put | |
319 | on the stack; if the size is exceeded static memory is used (except in | |
320 | procedures marked as RECURSIVE). Use the option :option:`-frecursive` to | |
321 | allow for recursive procedures which do not have a RECURSIVE attribute or | |
322 | for parallel programs. Use :option:`-fno-automatic` to never use the stack. | |
323 | ||
324 | This option currently only affects local arrays declared with constant | |
325 | bounds, and may not apply to all character variables. | |
326 | Future versions of GNU Fortran may improve this behavior. | |
327 | ||
328 | The default value for :samp:`{n}` is 65536. | |
329 | ||
330 | .. index:: fstack-arrays | |
331 | ||
332 | .. option:: -fstack-arrays | |
333 | ||
334 | Adding this option will make the Fortran compiler put all arrays of | |
335 | unknown size and array temporaries onto stack memory. If your program uses very | |
336 | large local arrays it is possible that you will have to extend your runtime | |
337 | limits for stack memory on some operating systems. This flag is enabled | |
338 | by default at optimization level :option:`-Ofast` unless | |
339 | :option:`-fmax-stack-var-size` is specified. | |
340 | ||
341 | .. index:: fpack-derived, structure packing | |
342 | ||
343 | .. option:: -fpack-derived | |
344 | ||
345 | This option tells GNU Fortran to pack derived type members as closely as | |
346 | possible. Code compiled with this option is likely to be incompatible | |
347 | with code compiled without this option, and may execute slower. | |
348 | ||
349 | .. index:: frepack-arrays, repacking arrays | |
350 | ||
351 | .. option:: -frepack-arrays | |
352 | ||
353 | In some circumstances GNU Fortran may pass assumed shape array | |
354 | sections via a descriptor describing a noncontiguous area of memory. | |
355 | This option adds code to the function prologue to repack the data into | |
356 | a contiguous block at runtime. | |
357 | ||
358 | This should result in faster accesses to the array. However it can introduce | |
359 | significant overhead to the function call, especially when the passed data | |
360 | is noncontiguous. | |
361 | ||
362 | .. index:: fshort-enums | |
363 | ||
364 | .. option:: -fshort-enums | |
365 | ||
366 | This option is provided for interoperability with C code that was | |
367 | compiled with the :option:`-fshort-enums` option. It will make | |
368 | GNU Fortran choose the smallest ``INTEGER`` kind a given | |
369 | enumerator set will fit in, and give all its enumerators this kind. | |
370 | ||
371 | .. index:: finline-arg-packing | |
372 | ||
373 | .. option:: -finline-arg-packing | |
374 | ||
375 | When passing an assumed-shape argument of a procedure as actual | |
376 | argument to an assumed-size or explicit size or as argument to a | |
377 | procedure that does not have an explicit interface, the argument may | |
378 | have to be packed, that is put into contiguous memory. An example is | |
379 | the call to ``foo`` in | |
380 | ||
381 | .. code-block:: fortran | |
382 | ||
383 | subroutine foo(a) | |
384 | real, dimension(*) :: a | |
385 | end subroutine foo | |
386 | subroutine bar(b) | |
387 | real, dimension(:) :: b | |
388 | call foo(b) | |
389 | end subroutine bar | |
390 | ||
391 | When :option:`-finline-arg-packing` is in effect, this packing will be | |
392 | performed by inline code. This allows for more optimization while | |
393 | increasing code size. | |
394 | ||
395 | :option:`-finline-arg-packing` is implied by any of the :option:`-O` options | |
396 | except when optimizing for size via :option:`-Os`. If the code | |
397 | contains a very large number of argument that have to be packed, code | |
398 | size and also compilation time may become excessive. If that is the | |
399 | case, it may be better to disable this option. Instances of packing | |
400 | can be found by using :option:`-Warray-temporaries`. | |
401 | ||
402 | .. index:: fexternal-blas | |
403 | ||
404 | .. option:: -fexternal-blas | |
405 | ||
406 | This option will make :command:`gfortran` generate calls to BLAS functions | |
407 | for some matrix operations like ``MATMUL``, instead of using our own | |
408 | algorithms, if the size of the matrices involved is larger than a given | |
409 | limit (see :option:`-fblas-matmul-limit`). This may be profitable if an | |
410 | optimized vendor BLAS library is available. The BLAS library will have | |
411 | to be specified at link time. | |
412 | ||
413 | .. index:: fblas-matmul-limit | |
414 | ||
415 | .. option:: -fblas-matmul-limit={n} | |
416 | ||
417 | Only significant when :option:`-fexternal-blas` is in effect. | |
418 | Matrix multiplication of matrices with size larger than (or equal to) :samp:`{n}` | |
419 | will be performed by calls to BLAS functions, while others will be | |
420 | handled by :command:`gfortran` internal algorithms. If the matrices | |
421 | involved are not square, the size comparison is performed using the | |
422 | geometric mean of the dimensions of the argument and result matrices. | |
423 | ||
424 | The default value for :samp:`{n}` is 30. | |
425 | ||
426 | .. index:: finline-matmul-limit | |
427 | ||
428 | .. option:: -finline-matmul-limit={n} | |
429 | ||
430 | When front-end optimization is active, some calls to the ``MATMUL`` | |
431 | intrinsic function will be inlined. This may result in code size | |
432 | increase if the size of the matrix cannot be determined at compile | |
433 | time, as code for both cases is generated. Setting | |
434 | ``-finline-matmul-limit=0`` will disable inlining in all cases. | |
435 | Setting this option with a value of :samp:`{n}` will produce inline code | |
436 | for matrices with size up to :samp:`{n}`. If the matrices involved are not | |
437 | square, the size comparison is performed using the geometric mean of | |
438 | the dimensions of the argument and result matrices. | |
439 | ||
440 | The default value for :samp:`{n}` is 30. The ``-fblas-matmul-limit`` | |
441 | can be used to change this value. | |
442 | ||
443 | .. index:: frecursive | |
444 | ||
445 | .. option:: -frecursive | |
446 | ||
447 | Allow indirect recursion by forcing all local arrays to be allocated | |
448 | on the stack. This flag cannot be used together with | |
449 | :option:`-fmax-stack-var-size=` or :option:`-fno-automatic`. | |
450 | ||
451 | .. index:: finit-local-zero, finit-derived, finit-integer, finit-real, finit-logical, finit-character | |
452 | ||
453 | .. option:: -finit-local-zero | |
454 | -finit-derived | |
455 | -finit-integer={n} | |
456 | -finit-real={<zero|inf|-inf|nan|snan>} | |
457 | -finit-logical={<true|false>} | |
458 | -finit-character={n} | |
459 | ||
460 | The :option:`-finit-local-zero` option instructs the compiler to | |
461 | initialize local ``INTEGER``, ``REAL``, and ``COMPLEX`` | |
462 | variables to zero, ``LOGICAL`` variables to false, and | |
463 | ``CHARACTER`` variables to a string of null bytes. Finer-grained | |
464 | initialization options are provided by the | |
465 | :option:`-finit-integer=n`, | |
466 | :option:`-finit-real=<zero|inf|-inf|nan|snan>` (which also initializes | |
467 | the real and imaginary parts of local ``COMPLEX`` variables), | |
468 | :option:`-finit-logical=<true|false>`, and | |
469 | :option:`-finit-character=n` (where :samp:`{n}` is an ASCII character | |
470 | value) options. | |
471 | ||
472 | With :option:`-finit-derived`, components of derived type variables will be | |
473 | initialized according to these flags. Components whose type is not covered by | |
474 | an explicit :option:`-finit-*` flag will be treated as described above with | |
475 | :option:`-finit-local-zero`. | |
476 | ||
477 | These options do not initialize | |
478 | ||
479 | * objects with the POINTER attribute | |
480 | ||
481 | * allocatable arrays | |
482 | ||
483 | * variables that appear in an ``EQUIVALENCE`` statement. | |
484 | ||
485 | (These limitations may be removed in future releases). | |
486 | ||
487 | Note that the :option:`-finit-real=nan` option initializes ``REAL`` | |
488 | and ``COMPLEX`` variables with a quiet NaN. For a signalling NaN | |
489 | use :option:`-finit-real=snan` ; note, however, that compile-time | |
490 | optimizations may convert them into quiet NaN and that trapping | |
491 | needs to be enabled (e.g. via :option:`-ffpe-trap`). | |
492 | ||
493 | The :option:`-finit-integer` option will parse the value into an | |
494 | integer of type ``INTEGER(kind=C_LONG)`` on the host. Said value | |
495 | is then assigned to the integer variables in the Fortran code, which | |
496 | might result in wraparound if the value is too large for the kind. | |
497 | ||
498 | Finally, note that enabling any of the :option:`-finit-*` options will | |
499 | silence warnings that would have been emitted by :option:`-Wuninitialized` | |
500 | for the affected local variables. | |
501 | ||
502 | .. index:: falign-commons, alignment of COMMON blocks | |
503 | ||
504 | .. option:: -falign-commons | |
505 | ||
506 | By default, :command:`gfortran` enforces proper alignment of all variables in a | |
507 | ``COMMON`` block by padding them as needed. On certain platforms this is mandatory, | |
508 | on others it increases performance. If a ``COMMON`` block is not declared with | |
509 | consistent data types everywhere, this padding can cause trouble, and | |
510 | :option:`-fno-align-commons` can be used to disable automatic alignment. The | |
511 | same form of this option should be used for all files that share a ``COMMON`` block. | |
512 | To avoid potential alignment issues in ``COMMON`` blocks, it is recommended to order | |
513 | objects from largest to smallest. | |
514 | ||
515 | .. index:: fno-protect-parens, re-association of parenthesized expressions | |
516 | ||
517 | .. option:: -fno-protect-parens | |
518 | ||
519 | By default the parentheses in expression are honored for all optimization | |
520 | levels such that the compiler does not do any re-association. Using | |
521 | :option:`-fno-protect-parens` allows the compiler to reorder ``REAL`` and | |
522 | ``COMPLEX`` expressions to produce faster code. Note that for the re-association | |
523 | optimization :option:`-fno-signed-zeros` and :option:`-fno-trapping-math` | |
524 | need to be in effect. The parentheses protection is enabled by default, unless | |
525 | :option:`-Ofast` is given. | |
526 | ||
527 | .. index:: frealloc-lhs, Reallocate the LHS in assignments | |
528 | ||
529 | .. option:: -frealloc-lhs | |
530 | ||
531 | An allocatable left-hand side of an intrinsic assignment is automatically | |
532 | (re)allocated if it is either unallocated or has a different shape. The | |
533 | option is enabled by default except when :option:`-std=f95` is given. See | |
534 | also :option:`-Wrealloc-lhs`. | |
535 | ||
536 | .. index:: faggressive-function-elimination, Elimination of functions with identical argument lists | |
537 | ||
538 | .. option:: -faggressive-function-elimination | |
539 | ||
540 | Functions with identical argument lists are eliminated within | |
541 | statements, regardless of whether these functions are marked | |
542 | ``PURE`` or not. For example, in | |
543 | ||
544 | .. code-block:: fortran | |
545 | ||
546 | a = f(b,c) + f(b,c) | |
547 | ||
548 | there will only be a single call to ``f``. This option only works | |
549 | if :option:`-ffrontend-optimize` is in effect. | |
550 | ||
551 | .. index:: frontend-optimize, Front-end optimization | |
552 | ||
553 | .. option:: -ffrontend-optimize | |
554 | ||
555 | This option performs front-end optimization, based on manipulating | |
556 | parts the Fortran parse tree. Enabled by default by any :option:`-O` option | |
557 | except :option:`-O0` and :option:`-Og`. Optimizations enabled by this option | |
558 | include: | |
559 | ||
560 | * inlining calls to ``MATMUL``, | |
561 | ||
562 | * elimination of identical function calls within expressions, | |
563 | ||
564 | * removing unnecessary calls to ``TRIM`` in comparisons and assignments, | |
565 | ||
566 | * replacing ``TRIM(a)`` with ``a(1:LEN_TRIM(a))`` and | |
567 | ||
568 | * short-circuiting of logical operators (``.AND.`` and ``.OR.``). | |
569 | ||
570 | It can be deselected by specifying :option:`-fno-frontend-optimize`. | |
571 | ||
572 | .. index:: frontend-loop-interchange, loop interchange, Fortran | |
573 | ||
574 | .. option:: -ffrontend-loop-interchange | |
575 | ||
576 | Attempt to interchange loops in the Fortran front end where | |
577 | profitable. Enabled by default by any :option:`-O` option. | |
578 | At the moment, this option only affects ``FORALL`` and | |
579 | ``DO CONCURRENT`` statements with several forall triplets. | |
580 | ||
581 | See :ref:`gcc:code-gen-options`, for information on more options | |
582 | offered by the GBE | |
3ed1b4ce | 583 | shared by :command:`gfortran`, :command:`gcc`, and other GNU compilers. |