[all-commits] [llvm/llvm-project] 1e55ec: [flang] SELECT CASE constructs with character sele...

Valentin Clement (バレンタイン クレメン) via All-commits all-commits at lists.llvm.org
Thu Jun 30 00:04:49 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1e55ec6666fa687b1a86bdaa95ea814557855fd1
      https://github.com/llvm/llvm-project/commit/1e55ec6666fa687b1a86bdaa95ea814557855fd1
  Author: Valentin Clement <clementval at gmail.com>
  Date:   2022-06-30 (Thu, 30 Jun 2022)

  Changed paths:
    M flang/include/flang/Lower/StatementContext.h
    M flang/lib/Lower/Bridge.cpp
    M flang/lib/Lower/ConvertExpr.cpp
    M flang/lib/Lower/IO.cpp
    M flang/test/Lower/select-case-statement.f90

  Log Message:
  -----------
  [flang] SELECT CASE constructs with character selectors that require a temp

Here is a character SELECT CASE construct that requires a temp to hold the
result of the TRIM intrinsic call:

```
module m
      character(len=6) :: s
    contains
      subroutine sc
        n = 0
        if (lge(s,'00')) then
          select case(trim(s))
          case('11')
             n = 1
          case default
             continue
          case('22')
             n = 2
          case('33')
             n = 3
          case('44':'55','66':'77','88':)
             n = 4
          end select
        end if
        print*, n
      end subroutine
    end module m
```

This SELECT CASE construct is implemented as an IF/ELSE-IF/ELSE comparison
sequence.  The temp must be retained until some comparison is successful.
At that point the temp may be freed.  Generalize statement context processing
to allow multiple finalize calls to do this, such that the program always
executes exactly one freemem call.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: klausler, vdonaldson

Differential Revision: https://reviews.llvm.org/D128852

Co-authored-by: V Donaldson <vdonaldson at nvidia.com>




More information about the All-commits mailing list