History log of /llvm-project/flang/lib/Evaluate/fold-integer.cpp (Results 1 – 25 of 92)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init, llvmorg-19.1.7
# 94963919 08-Jan-2025 Peter Klausler <pklausler@nvidia.com>

[flang] Fold LCOBOUND & UCOBOUND (#121411)

Implement constant folding for LCOBOUND and UCOBOUND intrinsic
functions. Moves some error detection code from intrinsics.cpp to
fold-integer.cpp so that

[flang] Fold LCOBOUND & UCOBOUND (#121411)

Implement constant folding for LCOBOUND and UCOBOUND intrinsic
functions. Moves some error detection code from intrinsics.cpp to
fold-integer.cpp so that erroneous calls get properly flagged and
converted into known errors.

show more ...


# fc97d2e6 18-Dec-2024 Peter Klausler <pklausler@nvidia.com>

[flang] Add UNSIGNED (#113504)

Implement the UNSIGNED extension type and operations under control of a
language feature flag (-funsigned).

This is nearly identical to the UNSIGNED feature that h

[flang] Add UNSIGNED (#113504)

Implement the UNSIGNED extension type and operations under control of a
language feature flag (-funsigned).

This is nearly identical to the UNSIGNED feature that has been available
in Sun Fortran for years, and now implemented in GNU Fortran for
gfortran 15, and proposed for ISO standardization in J3/24-116.txt.

See the new documentation for details; but in short, this is C's
unsigned type, with guaranteed modular arithmetic for +, -, and *, and
the related transformational intrinsic functions SUM & al.

show more ...


Revision tags: llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4
# ebc0163c 14-Nov-2024 Peter Klausler <pklausler@nvidia.com>

[flang] INT2 & INT8 can't be specific intrinsic functions (#115360)

I recently added support for the extension intrinsic functions INT2 and
INT8, and took the shortcut of defining them as specific

[flang] INT2 & INT8 can't be specific intrinsic functions (#115360)

I recently added support for the extension intrinsic functions INT2 and
INT8, and took the shortcut of defining them as specific intrinsic
functions that map to the standard INT() with hard-wired KIND= values
for the result. This works fine for references to these functions, but
leads to a compiler crash for an attempt to use their names in contexts
other than calling them, since their argument types aren't restricted to
single types and no concrete interface can be characterized for them. So
move them out of the table of specific intrinsic functions and into the
general table of intrinsics, and then handle them afterwards as if they
had been INT().

Fixes https://github.com/llvm/llvm-project/issues/115324.

show more ...


Revision tags: llvmorg-19.1.3, llvmorg-19.1.2
# 0f973ac7 02-Oct-2024 Peter Klausler <pklausler@nvidia.com>

[flang] Tag warnings with LanguageFeature or UsageWarning (#110304)

(This is a big patch, but it's nearly an NFC. No test results have
changed and all Fortran tests in the LLVM test suites work as

[flang] Tag warnings with LanguageFeature or UsageWarning (#110304)

(This is a big patch, but it's nearly an NFC. No test results have
changed and all Fortran tests in the LLVM test suites work as expected.)

Allow a parser::Message for a warning to be marked with the
common::LanguageFeature or common::UsageWarning that controls it. This
will allow a later patch to add hooks whereby a driver will be able to
decorate warning messages with the names of its options that enable each
particular warning, and to add hooks whereby a driver can map those
enumerators by name to command-line options that enable/disable the
language feature and enable/disable the messages.

The default settings in the constructor for LanguageFeatureControl were
moved from its header file into its C++ source file.

Hooks for a driver to use to map the name of a feature or warning to its
enumerator were also added.

To simplify the tagging of warnings with their corresponding language
feature or usage warning, to ensure that they are properly controlled by
ShouldWarn(), and to ensure that warnings never issue at code sites in
module files, two new Warn() member function templates were added to
SemanticsContext and other contextual frameworks. Warn() can't be used
before source locations can be mapped to scopes, but the bulk of
existing code blocks testing ShouldWarn() and FindModuleFile() before
calling Say() were convertible into calls to Warn(). The ones that were
not convertible were extended with explicit calls to
Message::set_languageFeature() and set_usageWarning().

show more ...


Revision tags: llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2
# ff567a4e 30-Jul-2024 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Fix folding of RANK(assumed-type assumed-rank) (#101027)

The code that deals with the special case of RANK(assumed-rank) in
intrinsic function folding wasn't handling the even more special

[flang] Fix folding of RANK(assumed-type assumed-rank) (#101027)

The code that deals with the special case of RANK(assumed-rank) in
intrinsic function folding wasn't handling the even more special case of
assumed-type assumed-rank dummy arguments.

show more ...


# 6f7e715e 30-Jul-2024 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Don't inject possibly invalid conversions while folding (#100842)

A couple of intrinsic functions have optional arguments. Don't insert
type conversions on those arguments when the actual a

[flang] Don't inject possibly invalid conversions while folding (#100842)

A couple of intrinsic functions have optional arguments. Don't insert
type conversions on those arguments when the actual arguments may not be
present at execution time, due to being OPTIONAL, allocatables, or
pointers.

show more ...


Revision tags: llvmorg-19.1.0-rc1, llvmorg-20-init
# 317277e4 24-Jun-2024 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Better error reporting for MOD/MODULO/NEAREST (#96114)

When the second argument to these intrinsic functions is a scalar
constant zero, emit a warning (if enabled) even if the first argumen

[flang] Better error reporting for MOD/MODULO/NEAREST (#96114)

When the second argument to these intrinsic functions is a scalar
constant zero, emit a warning (if enabled) even if the first argument is
not a constant.

show more ...


Revision tags: llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5
# 505f6da1 01-May-2024 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Ensure all warning/portability messages are guarded by Should… (#90518)

…Warn()

Many warning messages were being emitted unconditionally. Ensure that
all warnings are conditional on a tr

[flang] Ensure all warning/portability messages are guarded by Should… (#90518)

…Warn()

Many warning messages were being emitted unconditionally. Ensure that
all warnings are conditional on a true result from a call to
common::LanguageFeatureControl::ShouldWarn() so that it is easy for a
driver to disable them all, or, in the future, to provide per-warning
control over them.

show more ...


Revision tags: llvmorg-18.1.4
# e1ad2735 08-Apr-2024 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Clean up ISO_FORTRAN_ENV, fix NUMERIC_STORAGE_SIZE (#87566)

Address TODOs in the intrinsic module ISO_FORTRAN_ENV, and extend the
implementation of NUMERIC_STORAGE_SIZE so that the calculat

[flang] Clean up ISO_FORTRAN_ENV, fix NUMERIC_STORAGE_SIZE (#87566)

Address TODOs in the intrinsic module ISO_FORTRAN_ENV, and extend the
implementation of NUMERIC_STORAGE_SIZE so that the calculation of its
value is deferred until it is needed so that the effects of
-fdefault-integer-8 or -fdefault-real-8 are reflected. Emit a warning
when NUMERIC_STORAGE_SIZE is used from the module file and the default
integer and real sizes do not match.

Fixes https://github.com/llvm/llvm-project/issues/87476.

show more ...


Revision tags: llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4
# 307409a8 22-Feb-2024 David Spickett <david.spickett@linaro.org>

[flang] Fix warning fix

This fixes 73c646a3b27293f8cb4ba120de7bc01c223b4b5f.

I misread the #ifdefs and didn't realise that they were in
the middle of passing parameters to a function.

Move the wor

[flang] Fix warning fix

This fixes 73c646a3b27293f8cb4ba120de7bc01c223b4b5f.

I misread the #ifdefs and didn't realise that they were in
the middle of passing parameters to a function.

Move the workaround outside this.

show more ...


# 73c646a3 22-Feb-2024 David Spickett <david.spickett@linaro.org>

[flang] Fix warning when with clang-cl/msvc

\llvm\flang\lib\Evaluate\fold-integer.cpp(705,35): warning: lambda capture 'FromInt64' is not used [-Wunused-lambda-capture]

It is intentionally unused.


Revision tags: llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init
# 82e1e412 15-Jan-2024 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang][runtime] Treatment of NaN in MAXVAL/MAXLOC/MINVAL/MINLOC (#76999)

Detect NaN elements in data and handle them like gfortran does (at
runtime); namely, NaN can be returned if all the data ar

[flang][runtime] Treatment of NaN in MAXVAL/MAXLOC/MINVAL/MINLOC (#76999)

Detect NaN elements in data and handle them like gfortran does (at
runtime); namely, NaN can be returned if all the data are NaNs, but any
non-NaN value is preferable. Ensure that folding returns the same
results as runtime computation.

Fixes llvm-test-suite/Fortran/gfortran/regression/maxloc_2.f90 (and
probably others).

show more ...


# 26f2f939 30-Nov-2023 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Update to: Adjust checks of ICHAR/IACHAR argument length (#73972)

When applying ICHAR/IACHAR to a character constant with length greater
than one, resize the character constant to its first

[flang] Update to: Adjust checks of ICHAR/IACHAR argument length (#73972)

When applying ICHAR/IACHAR to a character constant with length greater
than one, resize the character constant to its first character.

show more ...


# aea94c90 30-Nov-2023 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Adjust checks of ICHAR/IACHAR argument length (#72312)

The compiler will now emit an error for length == 0 and an
off-by-default portability warning for length > 1. Previously, the
message

[flang] Adjust checks of ICHAR/IACHAR argument length (#72312)

The compiler will now emit an error for length == 0 and an
off-by-default portability warning for length > 1. Previously, the
message was an unconditional warning for length /= 1.

show more ...


Revision tags: llvmorg-17.0.6
# 0fdf9123 14-Nov-2023 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Fold MATMUL() (#72176)

Implements constant folding for matrix multiplication for all four
accepted type categories.


Revision tags: llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1
# 39f1860d 18-Sep-2023 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Fold NORM2() (#66240)

Fold references to the (relatively new) intrinsic function NORM2 at
compilation time when the argument(s) are all constants. (Getting this
done right involved some ch

[flang] Fold NORM2() (#66240)

Fold references to the (relatively new) intrinsic function NORM2 at
compilation time when the argument(s) are all constants. (Getting this
done right involved some changes to the API of the accumulator function
objects used by the DoReduction<> template, which rippled through some
other reduction function folding code.)

show more ...


Revision tags: llvmorg-17.0.0, llvmorg-17.0.0-rc4
# fe9b5876 29-Aug-2023 Peter Klausler <pklausler@nvidia.com>

[flang] Delete unused variable

A declaration for an unused variable was recently introduced
(by me) and is producing a warning in builds with the latest
clang. Delete it.


# c9da9c0d 23-Aug-2023 Peter Klausler <pklausler@nvidia.com>

[flang] Support PDT KIND parameters in later parameter kind expressions

Fortran allows an earlier-declared KIND type parameter of a parameterized
derived type to be used in the constant expression d

[flang] Support PDT KIND parameters in later parameter kind expressions

Fortran allows an earlier-declared KIND type parameter of a parameterized
derived type to be used in the constant expression defining the integer
kind of a later type parameter.

TYPE :: T(K,L)
INTEGER, KIND :: K
INTEGER(K), LEN :: L
...
END TYPE

Differential Revision: https://reviews.llvm.org/D159044https://reviews.llvm.org/D159044

show more ...


Revision tags: llvmorg-17.0.0-rc3
# 8383d768 18-Aug-2023 Peter Klausler <pklausler@nvidia.com>

[flang] Support SELECTED_LOGICAL_KIND() up to lowering

Process and fold the new F'2023 intrinsic function SELECTED_LOGICAL_KIND.

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


Revision tags: llvmorg-17.0.0-rc2
# 8926f0fe 04-Aug-2023 Peter Klausler <pklausler@nvidia.com>

[flang] Fold MERGE() of derived type values

Generalize FoldMerge() to accommodate derived type arguments and results,
rename it into Folder<T>::MERGE(), and remove it from the various
FoldIntrinsicF

[flang] Fold MERGE() of derived type values

Generalize FoldMerge() to accommodate derived type arguments and results,
rename it into Folder<T>::MERGE(), and remove it from the various
FoldIntrinsicFunction() routines for intrinsic types.

Fixes llvm-test-suite/Fortran/gfortran/regression/merge_init_expr_2.f90.

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

show more ...


# ca0525fa 01-Aug-2023 Peter Klausler <pklausler@nvidia.com>

[flang] Fix crash in location reduction folding with DIM= and scalar MASK=

The shape of an expanded scalar MASK= was incorrect in the template
code that folds FINDLOC/MAXLOC/MINLOC, leading to a vec

[flang] Fix crash in location reduction folding with DIM= and scalar MASK=

The shape of an expanded scalar MASK= was incorrect in the template
code that folds FINDLOC/MAXLOC/MINLOC, leading to a vector indexing
crash when a DIM= argument is also present.

Fixes https://github.com/llvm/llvm-project/issues/64286.

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

show more ...


Revision tags: llvmorg-17.0.0-rc1, llvmorg-18-init
# f9fdd4fd 24-Jul-2023 Peter Klausler <pklausler@nvidia.com>

[flang] Don't emit false errors on LBOUND/UBOUND of assumed-rank arrays

Folding of LBOUND/UBOUND on assumed-rank arrays could lead to bogus errors
later. This is a regression from a recent change i

[flang] Don't emit false errors on LBOUND/UBOUND of assumed-rank arrays

Folding of LBOUND/UBOUND on assumed-rank arrays could lead to bogus errors
later. This is a regression from a recent change intended to ensure that
patently bad DIM= arguments were caught even in the case of assumed-rank.
Rearrange the order of checks so that those bad DIM= argument values are
caught but otherwise defer LBOUND/UBOUND of assumed-rank arguments to
run time. (It was tempting to always fold LBOUND(ar,DIM=n) to 1, but
that would obscure the run time error required when 'n' is out of bounds,
including the case of a scalar 'ar'.)

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

show more ...


# 16c4b320 25-Jul-2023 Peter Klausler <pklausler@nvidia.com>

[flang] Correct handling of non-default lower bounds in ASSOCIATE with named constants

Work through several issues with LBOUND() and UBOUND() of ASSOCIATE
construct entities that have been associate

[flang] Correct handling of non-default lower bounds in ASSOCIATE with named constants

Work through several issues with LBOUND() and UBOUND() of ASSOCIATE
construct entities that have been associated with named constants or
subobjects of named constants that are sporting non-default lower bounds.
Sometimes the non-default lower bounds matter, sometimes they don't.
Add a fairly exhaustive test to work through the possibilities.

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

show more ...


# 221ba64e 18-Jul-2023 Peter Klausler <pklausler@nvidia.com>

[flang] Stricter checking of DIM= arguments to LBOUND/UBOUND/SIZE

DIM= arguments with constant values can be checked for validity
even when other arguments to an intrinsic function can't be
folded.

[flang] Stricter checking of DIM= arguments to LBOUND/UBOUND/SIZE

DIM= arguments with constant values can be checked for validity
even when other arguments to an intrinsic function can't be
folded. Handle errors with assumed-rank arguments as well.

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

show more ...


# 755180cf 10-Jul-2023 Peter Klausler <pklausler@nvidia.com>

[flang] Avoid bogus errors with LBOUND/UBOUND(assumed rank array, DIM=)

Don't emit bogus compile-time error messages about out-of-range values
for the DIM= argument to LBOUND/BOUND when the array in

[flang] Avoid bogus errors with LBOUND/UBOUND(assumed rank array, DIM=)

Don't emit bogus compile-time error messages about out-of-range values
for the DIM= argument to LBOUND/BOUND when the array in question is an
assumed-rank dummy array argument.

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

show more ...


1234