Hi Bernhard,
On 1/21/20 12:43 PM, Bernhard Reutner-Fischer wrote:
+ if (sym->attr.proc == PROC_UNKNOWN)
+ for (gfc_namespace *ns = sym->ns; ns; ns = ns->parent)
+ if (ns->has_implicit_none_export)
+ has_implicit_none_export = true;
s/;/, break;/
If we don't do this for >= -O1 already.
We don't. All three variants generate for -O0 to -O3 a different
optimized tree. (I didn't look at RTL or assembler.) But it is also not
completely clear to me which approach is the best. I think it also
depends how it is converted into assembler and what the hardware
actually does.
I was thinking about all three variants and had settled for the shortest
when sending the patch. The third variant would be:
for (gfc_namespace *ns = sym->ns;
ns && !has_implicit_none_export;
ns = ns->parent)
if (ns->has_implicit_none_export)
has_implicit_none_export = true;
which may or may not be faster in execution – the conditional assignment
might be faster, but one has to do the "&&" operation in each step (can
be AND_EXPR; it does not need to be THEN_IF_EXPR). — However, I find it
less readable.
At the end, it does not really matter as the loop body and expressions
are small and the typical nest-depth is probably two (module + module
procedures) or three (module procedures + BLOCK or host-associated
procedure) such that an early abort is not really worthwhile. Even with
more nesting levels, the chance that one has many sym->attr.proc ==
PROC_UNKNOWN in a deeply nested scoping unit should be low. (And if it
is not, it will be still not the hot loop for that code.)
However, I have now used the version with "break", which is also fine.
r10-6108-gb31f80231df9ce6d9b50c62d28b8d2a4654ef564
Cheers,
Tobias