[Flang-dev] f18 and PRESENT

Troy Johnson troyj at cray.com
Fri Oct 12 11:51:57 EDT 2018


I'm curious how f18 will translate PRESENT (Fortran 2018 16.9.152) given the various checks imposed by 15.5.2.12.  There seems to be a trend toward using OPTIONAL arguments, which then litters code with PRESENT checks, frequently inside loops.  Sometimes it's possible for a compiler to hoist the check and version the loop, but the difficulty of that process depends on how PRESENT is expanded.  Will it be a single conditional or multiple nested conditionals?  For example, for an OPTIONAL ALLOCATABLE dummy argument, one might need PRESENT to be something like:

  IF (ARG_EXISTS(X)) THEN
    IF (ALLOCATED(X)) THEN
      ! code originally guarded by IF (PRESENT(X))
    END IF
  END IF

So then an optimization pass that tries to hoist PRESENT from loops is faced with two nested conditions as opposed to one.  I suppose the number of checks might depend on the dope vector format that f18 intends to use.

-Troy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.flang-compiler.org/pipermail/flang-dev_lists.flang-compiler.org/attachments/20181012/617a0256/attachment-0001.html>


More information about the flang-dev mailing list