Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flang] Incorrect execution results of max0 intrinsic function for various arguments #132646

Open
ohno-fj opened this issue Mar 23, 2025 · 1 comment

Comments

@ohno-fj
Copy link

ohno-fj commented Mar 23, 2025

Version of flang : 21.0.0(3e6f618e86f5fbad2c2d5802416ec3d3366a2837)/AArch64

As in the attached program, when max0 intrinsic function is given 1, 2, and 8 byte in addition to default integer (4 byte), the results of the function are all default integer (4 byte).

max0 is written as accept more argument types than specified. by:

https://github.com/llvm/llvm-project/blob/main/flang/docs/Extensions.md
Extensions, deletions, and legacy features supported by default
- Specific intrinsics AMAX0, AMAX1, AMIN0, AMIN1, DMAX1, DMIN1, MAX0, MAX1, MIN0, and MIN1
  accept more argument types than specified.
  They are replaced by the related generics followed by conversions to the specified result types.

Therefore, this program is correct.
And it appears that flang does not support extended argument types.
I have confirmed similar results only for min0.
I haven't checked the other intrinsic functions.

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

max0.f90:

program main
  print *,kind(max0(1_1,2_1))
  print *,kind(max0(1_2,2_2))
  print *,kind(max0(1_4,2_4))
  print *,kind(max0(1_8,2_8))

  print *,kind(min0(1_1,2_1))
  print *,kind(min0(1_2,2_2))
  print *,kind(min0(1_4,2_4))
  print *,kind(min0(1_8,2_8))
end program main
$ flang max0.f90; ./a.out
 4
 4
 4
 4
 4
 4
 4
 4
$
$ gfortran max0.f90; ./a.out
           1
           2
           4
           8
           1
           2
           4
           8
$
$ ifx max0.f90; ./a.out
           1
           2
           4
           8
           1
           2
           4
           8
$
@ohno-fj ohno-fj added the flang Flang issues not falling into any other category label Mar 23, 2025
@eugeneepshteyn eugeneepshteyn added flang:frontend and removed flang Flang issues not falling into any other category labels Mar 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 24, 2025

@llvm/issue-subscribers-flang-frontend

Author: None (ohno-fj)

``` Version of flang : 21.0.0(3e6f618)/AArch64 ```

As in the attached program, when max0 intrinsic function is given 1, 2, and 8 byte in addition to default integer (4 byte), the results of the function are all default integer (4 byte).

max0 is written as accept more argument types than specified. by:

https://github.com/llvm/llvm-project/blob/main/flang/docs/Extensions.md
Extensions, deletions, and legacy features supported by default
- Specific intrinsics AMAX0, AMAX1, AMIN0, AMIN1, DMAX1, DMIN1, MAX0, MAX1, MIN0, and MIN1
  accept more argument types than specified.
  They are replaced by the related generics followed by conversions to the specified result types.

Therefore, this program is correct.
And it appears that flang does not support extended argument types.
I have confirmed similar results only for min0.
I haven't checked the other intrinsic functions.

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

max0.f90:

program main
  print *,kind(max0(1_1,2_1))
  print *,kind(max0(1_2,2_2))
  print *,kind(max0(1_4,2_4))
  print *,kind(max0(1_8,2_8))

  print *,kind(min0(1_1,2_1))
  print *,kind(min0(1_2,2_2))
  print *,kind(min0(1_4,2_4))
  print *,kind(min0(1_8,2_8))
end program main
$ flang max0.f90; ./a.out
 4
 4
 4
 4
 4
 4
 4
 4
$
$ gfortran max0.f90; ./a.out
           1
           2
           4
           8
           1
           2
           4
           8
$
$ ifx max0.f90; ./a.out
           1
           2
           4
           8
           1
           2
           4
           8
$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants