[PATCH] D104587: [flang] Implement constant folding for the NOT intrinsic
Pete Steinfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 18 19:19:39 PDT 2021
PeteSteinfeld created this revision.
PeteSteinfeld requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
I implemented constant folding for the NOT intrinsic and added some tests.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D104587
Files:
flang/lib/Evaluate/fold-integer.cpp
flang/test/Evaluate/folding01.f90
Index: flang/test/Evaluate/folding01.f90
===================================================================
--- flang/test/Evaluate/folding01.f90
+++ 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
Index: flang/lib/Evaluate/fold-integer.cpp
===================================================================
--- flang/lib/Evaluate/fold-integer.cpp
+++ flang/lib/Evaluate/fold-integer.cpp
@@ -523,6 +523,9 @@
}
return result.value;
}));
+ } else if (name == "not") {
+ return FoldElementalIntrinsic<T, T>(
+ context, std::move(funcRef), &Scalar<T>::NOT);
} else if (name == "precision") {
if (const auto *cx{UnwrapExpr<Expr<SomeReal>>(args[0])}) {
return Expr<T>{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<T>{std::move(funcRef)};
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104587.353156.patch
Type: text/x-patch
Size: 1448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210619/07bbc19f/attachment.bin>
More information about the llvm-commits
mailing list