Submitted by Jerry DeLisle on Nov. 8, 2010, 2:40 a.m.

Message ID | 4CD76320.8090201@frontier.com |
---|---|

State | New |

Headers | show |

On Monday 08 November 2010 03:40:32 Jerry DeLisle wrote: > Hi all, > > The problem here is that we are expanding a large array constructor that > contains a function that does not reduce (ie. rand(0)). The solution is a > small adjustment to gfc_is_constant_expr which is used to determine > whether or not to expand a constructor. In this case, simply treating an > non pure function as not constant. > Hello, I think it may miss some simplification opportunities. For example, transformational functions and inquiry functions are not marked pure as far as I know. But some of them have simplification functions. As the klass is not saved anywhere in intrinsic.c's add_sym (at least not in the CLASS_IMPURE case), maybe would it work to check the presence of a simplification function pointer ? Or maybe gfc_intrinsic_sym's flags !pure && !inquiry && !transformational would match CLASS_IMPURE ? Mikael PS: Is it expected that the and/or/xor procedures are marked as CLASS_IMPURE ?

```
On 11/08/2010 01:13 PM, Mikael Morin wrote:
> PS: Is it expected that the and/or/xor procedures are marked as CLASS_IMPURE
The CLASS_* names come from the Fortran standard (where the term
"impure" is a F2008 addition). Well, looking at the standard you find:
13.7.10 ALL (MASK [, DIM])
Class. Transformational function.
The procedures "OR" and "XOR" are GNU extensions; the manual does not
tell which kind of functions they are, but the standard Fortran "IOR"
and "IEOR", which are the Fortran-standard replacements, are "elemental
functions". If one changes OR and XOR to elemental, one also needs to
update the documentation, cf.
http://gcc.gnu.org/onlinedocs/gfortran/OR.html and
http://gcc.gnu.org/onlinedocs/gfortran/XOR.html
Tobias
```

Index: expr.c =================================================================== --- expr.c (revision 166382) +++ expr.c (working copy) @@ -923,7 +923,8 @@ gfc_is_constant_expr (gfc_expr *e) return 1; /* Call to intrinsic with at least one argument. */ - if (e->value.function.isym && e->value.function.actual) + if (e->symtree && e->symtree->n.sym->attr.pure + && e->value.function.isym && e->value.function.actual) { for (arg = e->value.function.actual; arg; arg = arg->next) if (!gfc_is_constant_expr (arg->expr))