[PATCH] D81940: [flang] AMAX0, MIN1... rewrite to MAX/MIN: make result conversion explicit

Jean Perier via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 17 06:58:43 PDT 2020


jeanPerier marked an inline comment as done.
jeanPerier added inline comments.


================
Comment at: flang/lib/Evaluate/fold-implementation.h:696
+    if (type.category() == resultType.category()) {
+      if (type.kind() > resultType.kind()) {
+        resultTypeArg = &args[j];
----------------
schweitz wrote:
> Is sign-extension always correct? Table 16.3 suggests AMAX0 has //default// integer arguments, which would possibly suggest truncation for something like INTEGER_16.
The code here is supporting a non standard extension. In standard Fortran, an INTEGER(16) argument in AMAX0 is illegal (unless it is the default integer type). Pgfortran, xlf and ifortran support non standard argument types in AMAX0. XLF and ifort never truncate the arguments but instead use `REAL(MAX(a, b), 4)`, and that what was previously decided to do for f18 (documented in Extensions.md) . So in the INTEGER(16), the MAX would be performed on INTEGER(16) and the result be converted to REAL(4).
Pgfortran behaviour is to truncates the argument in general, but that is not true for all extremum specific intrinsics, so it is simpler and safer to align with ifort/xlf on this extension.
A warning is emitted in such non standard usage (since numerical stability between pgfortran/f18, ifort, xlf might be affected).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81940/new/

https://reviews.llvm.org/D81940





More information about the llvm-commits mailing list