diff --git a/flang/lib/Evaluate/fold-integer.cpp b/flang/lib/Evaluate/fold-integer.cpp --- a/flang/lib/Evaluate/fold-integer.cpp +++ b/flang/lib/Evaluate/fold-integer.cpp @@ -523,6 +523,9 @@ } return result.value; })); + } else if (name == "not") { + return FoldElementalIntrinsic( + context, std::move(funcRef), &Scalar::NOT); } else if (name == "precision") { if (const auto *cx{UnwrapExpr>(args[0])}) { return Expr{std::visit( @@ -657,7 +660,7 @@ // TODO: // cshift, dot_product, eoshift, // findloc, iall, iany, iparity, ibits, image_status, ishftc, - // matmul, maxloc, minloc, not, pack, product, reduce, + // matmul, maxloc, minloc, pack, product, reduce, // sign, spread, sum, transfer, transpose, unpack return Expr{std::move(funcRef)}; } diff --git a/flang/test/Evaluate/folding01.f90 b/flang/test/Evaluate/folding01.f90 --- a/flang/test/Evaluate/folding01.f90 +++ b/flang/test/Evaluate/folding01.f90 @@ -135,4 +135,8 @@ logical, parameter :: test_max_a1 = all(max(x1a, x2a).EQ.[11, 12, 13, 14]) logical, parameter :: test_min_a1 = all(min(x1a, x2a).EQ.[1, 2, 3, 4]) + logical, parameter :: test_not_zero = not(0).EQ.-1 + logical, parameter :: test_not_neg_one = not(-1).EQ.0 + logical, parameter :: test_not_array = all(not([5, 6, 7]).EQ.[-6, -7, -8]) + end module