History log of /llvm-project/flang/lib/Evaluate/fold-logical.cpp (Results 1 – 25 of 48)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init, llvmorg-19.1.7
# c28a7c1e 23-Dec-2024 vdonaldson <37090318+vdonaldson@users.noreply.github.com>

[flang] Modifications to ieee_support_halting (#120747)

The F23 standard requires that a call to intrinsic module procedure
ieee_support_halting be foldable to a constant at compile time in some
c

[flang] Modifications to ieee_support_halting (#120747)

The F23 standard requires that a call to intrinsic module procedure
ieee_support_halting be foldable to a constant at compile time in some
contexts. See for example F23 Clause 10.1.11 [Specification expression]
list item (13), Clause 1.1.12 [Constant expression] list item (11), and
references to specification and constant expressions elsewhere, such as
constraints C1012, C853, and C704.

Some Arm processors allow a user to control processor behavior when an
arithmetic exception is signaled, and some Arm processors do not have
this capability. An Arm executable will run on either type of processor,
so it is effectively unknown at compile time whether or not this support
will be available at runtime. This in conflict with the standard
requirement.

This patch addresses this conflict by implementing ieee_support_halting
calls on Arm processors to check if this capability is present at
runtime. A call to ieee_support_halting in a constant context, such as
in the specification part of a program unit, will generate a compile
time "cannot be computed as a constant value" error. The expectation is
that such calls are unlikely to appear in production code.

Code generation for other processors will continue to generate a compile
time constant result for ieee_support_halting calls.

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
# 6003be7e 04-Dec-2024 vdonaldson <37090318+vdonaldson@users.noreply.github.com>

[flang] IEEE_GET_UNDERFLOW_MODE, IEEE_SET_UNDERFLOW_MODE (#118551)

Implement IEEE_GET_UNDERFLOW_MODE and IEEE_SET_UNDERFLOW_MODE. Update
IEEE_SUPPORT_UNDERFLOW_CONTROL to enable support for indvidu

[flang] IEEE_GET_UNDERFLOW_MODE, IEEE_SET_UNDERFLOW_MODE (#118551)

Implement IEEE_GET_UNDERFLOW_MODE and IEEE_SET_UNDERFLOW_MODE. Update
IEEE_SUPPORT_UNDERFLOW_CONTROL to enable support for indvidual REAL
kinds.

show more ...


Revision tags: llvmorg-19.1.5, llvmorg-19.1.4, 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, llvmorg-19.1.0-rc1, llvmorg-20-init
# 4b57fe65 18-Jun-2024 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Fold IEEE_SUPPORT_xxx() intrinsic functions (#95866)

All of the IEEE_SUPPORT_xxx() intrinsic functions must fold to constant
logical values when they have constant arguments; and since they

[flang] Fold IEEE_SUPPORT_xxx() intrinsic functions (#95866)

All of the IEEE_SUPPORT_xxx() intrinsic functions must fold to constant
logical values when they have constant arguments; and since they fold to
.TRUE. for currently support architectures, always fold them. But also
put in the infrastructure whereby a driver can initialize Evaluate's
target information to set some of them to .FALSE. if that becomes
necessary.

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 ...


# 2e2ac6f2 22-Apr-2024 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Fix build warning (#89686)

A recent patch had three declared but unused variables in it, triggering
a warning in some build bots. Remove them.


# 1444e5ac 22-Apr-2024 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Complete implementation of OUT_OF_RANGE() (#89334)

The intrinsic function OUT_OF_RANGE() lacks support in lowering and the
runtime. This patch obviates a need for any such support by implem

[flang] Complete implementation of OUT_OF_RANGE() (#89334)

The intrinsic function OUT_OF_RANGE() lacks support in lowering and the
runtime. This patch obviates a need for any such support by implementing
OUT_OF_RANGE() via rewriting in semantics. This rewriting of
OUT_OF_RANGE() calls replaces the existing code that folds
OUT_OF_RANGE() calls with constant arguments.

Some changes and fixes were necessary outside of OUT_OF_RANGE()'s
folding code (now rewriting code), whose testing exposed some other
issues worth fixing.

- The common::RealDetails<> template class was recoded in terms of a new
base class with a constexpr constructor, so that the the characteristics
of the various REAL kinds could be queried dynamically as well. This
affected some client usage.
- There were bugs in the code that folds TRANSFER() when the type of X
or MOLD was REAL(10) -- this is a type that occupies 16 bytes per
element in execution memory but only 10 bytes (was 12) in the data of
std::vector<Scalar<>> in a Constant<>.
- Folds of REAL->REAL conversions weren't preserving infinities.

show more ...


Revision tags: llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, 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 ...


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
# 67f15e76 13-Nov-2023 Peter Klausler <35819229+klausler@users.noreply.github.com>

[flang] Fold IS_IOSTAT_END() & IS_IOSTAT_EOR() (#70971)

These intrinsic functions are not particularly valuable -- one can just
compare a value to IOSTAT_END or IOSTAT_EOR directly -- but they are

[flang] Fold IS_IOSTAT_END() & IS_IOSTAT_EOR() (#70971)

These intrinsic functions are not particularly valuable -- one can just
compare a value to IOSTAT_END or IOSTAT_EOR directly -- but they are in
the standard and are allowed to appear in constant expressions, so
here's code to fold them.

show more ...


Revision tags: 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, llvmorg-17.0.0-rc3
# 54784b18 18-Aug-2023 Peter Klausler <pklausler@nvidia.com>

[flang] Fold OUT_OF_RANGE()

Fold the F'2018 intrinsic function OUT_OF_RANGE(), which returns .TRUE.
when a conversion of an integer or real value to an integer or real type
would yield an overflow o

[flang] Fold OUT_OF_RANGE()

Fold the F'2018 intrinsic function OUT_OF_RANGE(), which returns .TRUE.
when a conversion of an integer or real value to an integer or real type
would yield an overflow or (for real->integer only) invalid operand
exception. Test all type combinations, with both rounding possibilities
for the real->integer cases.

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

show more ...


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 ...


Revision tags: llvmorg-17.0.0-rc1, llvmorg-18-init
# 08bfc002 29-Jun-2023 Peter Klausler <pklausler@nvidia.com>

[flang] Don't warn about a NaN argument to ISNAN()

Don't emit a warning when a compile-time constant argument to
ISNAN() or IEEE_IS_NAN() is a NaN.

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

[flang] Don't warn about a NaN argument to ISNAN()

Don't emit a warning when a compile-time constant argument to
ISNAN() or IEEE_IS_NAN() is a NaN.

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

show more ...


# 09ea692d 29-Jun-2023 V Donaldson <vdonaldson@nvidia.com>

[flang] IEEE_ARITHMETIC intrinsic module procedures

Implement

- IEEE_CLASS
- IEEE_COPY_SIGN
- IEEE_GET_ROUNDING_MODE
- IEEE_IS_FINITE
- IEEE_IS_NAN
- IEEE_IS_NEGATIVE
- IEEE_IS_NORMAL
- IEE

[flang] IEEE_ARITHMETIC intrinsic module procedures

Implement

- IEEE_CLASS
- IEEE_COPY_SIGN
- IEEE_GET_ROUNDING_MODE
- IEEE_IS_FINITE
- IEEE_IS_NAN
- IEEE_IS_NEGATIVE
- IEEE_IS_NORMAL
- IEEE_SET_ROUNDING_MODE
- IEEE_SIGNBIT
- IEEE_SUPPORT_ROUNDING
- IEEE_UNORDERED
- IEEE_VALUE

for all REAL kinds (2, 3, 4, 8, 10, 16) where applicable.

show more ...


Revision tags: llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2
# 6f5df419 14-Apr-2023 Jean Perier <jperier@nvidia.com>

[flang] Fold IS_CONTIGUOUS for TYPE(*) when possible

TYPE(*) arguments fell through in IS_CONTIGUOUS folding
because they are not Expr<SomeType>. Expose entry point for
symbols in IsContiguous and u

[flang] Fold IS_CONTIGUOUS for TYPE(*) when possible

TYPE(*) arguments fell through in IS_CONTIGUOUS folding
because they are not Expr<SomeType>. Expose entry point for
symbols in IsContiguous and use that.

The added test revealed that IS_CONTIGUOUS was folded to
false for assumed rank arguments. Fix this: the contiguity of
assumed rank without the CONTIGUOUS argument can only be
verified at runtime.

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

show more ...


Revision tags: llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4
# 75ddabd5 27-Feb-2023 David Truby <david.truby@arm.com>

[flang] Implement ieee_is_normal

This patch adds an implementation of ieee_is_normal using a call
to llvm.is.fpclass.

Depends on D144649

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


# 4ee8aef4 23-Feb-2023 David Truby <david.truby@arm.com>

[flang] Implement isnan and ieee_is_nan intrinsics

To implement these we call the LLVM intrinsic is.fpclass indicating that
we are checking for either a quiet or signalling NaN.

Differential Revisi

[flang] Implement isnan and ieee_is_nan intrinsics

To implement these we call the LLVM intrinsic is.fpclass indicating that
we are checking for either a quiet or signalling NaN.

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

show more ...


Revision tags: llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init
# e4c4841e 22-Jan-2023 Shivam Gupta <shivam98.tkg@gmail.com>

[Flang][NFC] fix a cpoy-paste in fold-logical.cpp

found by PVS-Studio.


Revision tags: llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2
# 94896994 21-Sep-2022 Peter Klausler <pklausler@nvidia.com>

[flang] Fold IS_CONTIGUOUS() to .FALSE. when it is known to be

At present, IS_CONTIGUOUS() can only either fold to .TRUE. or
remain unknown. The underlying analysis, however, is capable
of returnin

[flang] Fold IS_CONTIGUOUS() to .FALSE. when it is known to be

At present, IS_CONTIGUOUS() can only either fold to .TRUE. or
remain unknown. The underlying analysis, however, is capable
of returning a tri-state result (true, false, or unknown).
Extend and expose it to folding so that IS_CONTIGUOUS() can
fold to .FALSE. as well as to .TRUE. when contiguity is
known.

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

show more ...


Revision tags: llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2, llvmorg-14.0.0-rc1, llvmorg-15-init, llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2, llvmorg-13.0.1-rc1
# e723c69b 28-Oct-2021 Peter Klausler <pklausler@nvidia.com>

[flang] Fold DOT_PRODUCT()

Implement constant folding of the intrinsic function DOT_PRODUCT().

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


# 2f2fce8e 22-Aug-2022 Tarun Prabhu <tarun@lanl.gov>

[flang] Fold F08 parity intrinsic

Perform compile-time folding of the F08 parity intrinsic when all parameters are compile-time constants.

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


# 7709f12e 19-Jul-2022 Tarun Prabhu <tarunprabhu@gmail.com>

Bitwise comparison intrinsics

This patch implements lowering for the F08 bitwise comparison intrinsics
(BGE, BGT, BLE and BLT).

This does not create any runtime functions since the functionality is

Bitwise comparison intrinsics

This patch implements lowering for the F08 bitwise comparison intrinsics
(BGE, BGT, BLE and BLT).

This does not create any runtime functions since the functionality is
simple enough to carry out in IR.

The existing semantic check has been changed because it unconditionally
converted the arguments to the largest possible integer type. This
resulted in the argument with the smaller bit-size being sign-extended.
However, the standard requires the argument with the smaller bit-size to
be zero-extended.

Reviewed By: klausler, jeanPerier

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

show more ...


# ae93d8ea 05-Jul-2022 Peter Klausler <pklausler@nvidia.com>

[flang] Fold TRANSFER()

Fold usage of the raw data reinterpretation intrinsic function TRANSFER().

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


12