public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Scalarization of simplification of constant expressions?
@ 2020-10-05 19:59 Harald Anlauf
  2020-10-06  5:44 ` Paul Richard Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Harald Anlauf @ 2020-10-05 19:59 UTC (permalink / raw)
  To: fortran

Dear all,

the restrictions on what can be used in constant expressions have been
greatly reduced in F2018, so one might want to simplify more than what
was possible before.

E.g. the following is currently not simplified at compile time:

  print *, index('abcd',['c'], .true. )
  print *, index('abcd', 'b' ,[.true.])

c.f. PR95979, while the scalar variants do simplify.

Is there something like scalarization also available for simplification
of constant expressions?

Regards,
Harald


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Scalarization of simplification of constant expressions?
  2020-10-05 19:59 Scalarization of simplification of constant expressions? Harald Anlauf
@ 2020-10-06  5:44 ` Paul Richard Thomas
  2020-10-06 21:34   ` Aw: " Harald Anlauf
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2020-10-06  5:44 UTC (permalink / raw)
  To: Harald Anlauf; +Cc: fortran

Hi Harald,

Yes, there is a scalarizer for elemental calls:
expr.c(scalarize_intrinsic_call) first appears in 2007.

Cheers

Paul


On Mon, 5 Oct 2020 at 20:59, Harald Anlauf <anlauf@gmx.de> wrote:

> Dear all,
>
> the restrictions on what can be used in constant expressions have been
> greatly reduced in F2018, so one might want to simplify more than what
> was possible before.
>
> E.g. the following is currently not simplified at compile time:
>
>   print *, index('abcd',['c'], .true. )
>   print *, index('abcd', 'b' ,[.true.])
>
> c.f. PR95979, while the scalar variants do simplify.
>
> Is there something like scalarization also available for simplification
> of constant expressions?
>
> Regards,
> Harald
>
>

-- 
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Aw: Re: Scalarization of simplification of constant expressions?
  2020-10-06  5:44 ` Paul Richard Thomas
@ 2020-10-06 21:34   ` Harald Anlauf
  0 siblings, 0 replies; 3+ messages in thread
From: Harald Anlauf @ 2020-10-06 21:34 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: fortran

Hi Paul,
 
> Yes, there is a scalarizer for elemental calls: expr.c(scalarize_intrinsic_call) first appears in 2007.
 
thanks for pointing this out.
 
However, can you elaborate a little bit on how to use it?
 
A grep show just two places where it is used, and only in expr.c:
 
 
In gfc_simplify_expr:
 

      if (p->expr_type == EXPR_FUNCTION)
    {
      if (p->symtree)
        isym = gfc_find_function (p->symtree->n.sym->name);
      if (isym && isym->elemental)
        scalarize_intrinsic_call (p, false);
    }
 
 

In gfc_check_init_expr:
 

    /* Try to scalarize an elemental intrinsic function that has an
       array argument.  */
    isym = gfc_find_function (e->symtree->n.sym->name);
    if (isym && isym->elemental
        && (t = scalarize_intrinsic_call (e, true)))
      break;
 
 
Do you have an example how to apply it?
 
Thanks,
Harald
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-06 21:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-05 19:59 Scalarization of simplification of constant expressions? Harald Anlauf
2020-10-06  5:44 ` Paul Richard Thomas
2020-10-06 21:34   ` Aw: " Harald Anlauf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).