[flang-commits] [flang] [Flang] Allow Intrinsic simpification with min/maxloc dim and scalar result (PR #81619)

Pete Steinfeld via flang-commits flang-commits at lists.llvm.org
Wed Feb 14 10:44:19 PST 2024


psteinfeld wrote:

> OK thanks for checking - Maybe this cannot get away with converting the array to an int. Let me put up a new version where it changes the alloc type and if there are still problems we can try and figure out why.

I've looked at the test results.  There were two problems.  First, one of our tests started issuing warnings at compile time when lowering.  Here's an example that shows the problem:
```
program bug
  real :: x(2) = [ 1.0, 2.0 ]
  call test(x,-1)
contains
  subroutine test(array, dim)
    real,intent(in) :: array(2)
    integer,intent(in) :: dim
    integer :: loc
    loc = minloc(array,dim)
  end subroutine
end program
```
Second,I'm seeing differences in what floating point exceptions get raised when doing IEEE arithmetic.  Here's a program that shows that difference:
```
program bug
  real :: a(3), nan, positive_infinity

  nan = 0.0
  positive_infinity = 0.0
  nan = 0.0/nan
  positive_infinity = 1.0/positive_infinity

  a(3) = positive_infinity
  a(1:2) = nan
  if (minloc (a, dim = 1).ne.3) STOP 5
end
```


https://github.com/llvm/llvm-project/pull/81619


More information about the flang-commits mailing list