[PATCH] D85632: [Attributor] Connect AAPotentialValues with AAValueSimplify
Shinji Okumura via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 10 01:32:50 PDT 2020
okura created this revision.
Herald added subscribers: llvm-commits, kuter, uenoku, hiraditya.
Herald added a reviewer: uenoku.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: homerdin.
Herald added a project: LLVM.
okura requested review of this revision.
Herald added a reviewer: sstefan1.
Herald added a reviewer: baziotis.
Herald added a subscriber: bbn.
This patch enables `AAValueSimplify` to use information from `AAPotentialValues`.
https://reviews.llvm.org/D85632
Files:
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp
===================================================================
--- llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -4474,24 +4474,42 @@
return true;
}
- bool askSimplifiedValueForAAValueConstantRange(Attributor &A) {
+ /// Returns a candidate is found or not
+ /// \p failAll is true when nullptr is returned by all other AAs
+ /// If at least one AA returns llvm::None, a candidate may be found in later
+ /// iteration.
+ template <typename AAType>
+ bool askSimplifiedValueFor(Attributor &A, bool &failAll) {
if (!getAssociatedValue().getType()->isIntegerTy())
return false;
- const auto &ValueConstantRangeAA =
- A.getAAFor<AAValueConstantRange>(*this, getIRPosition());
+ const auto &AA =
+ A.getAAFor<AAType>(*this, getIRPosition(), /* TrackDependence */ true,
+ DepClassTy::OPTIONAL);
- Optional<ConstantInt *> COpt =
- ValueConstantRangeAA.getAssumedConstantInt(A);
- if (COpt.hasValue()) {
- if (auto *C = COpt.getValue())
+ Optional<ConstantInt *> COpt = AA.getAssumedConstantInt(A);
+
+ if (!COpt.hasValue()) {
+ failAll = false;
+ return false;
+ } else {
+ if (auto *C = COpt.getValue()) {
SimplifiedAssociatedValue = C;
- else
+ return true;
+ } else {
return false;
- } else {
- SimplifiedAssociatedValue = llvm::None;
+ }
}
- return true;
+ }
+
+ bool askSimplifiedValueForOtherAAs(Attributor &A) {
+ bool failAll = true;
+ SimplifiedAssociatedValue = llvm::None;
+ if (askSimplifiedValueFor<AAValueConstantRange>(A, failAll))
+ return true;
+ if (askSimplifiedValueFor<AAPotentialValues>(A, failAll))
+ return true;
+ return !failAll;
}
/// See AbstractAttribute::manifest(...).
@@ -4598,7 +4616,7 @@
bool AllCallSitesKnown;
if (!A.checkForAllCallSites(PredForCallSite, *this, true,
AllCallSitesKnown))
- if (!askSimplifiedValueForAAValueConstantRange(A))
+ if (!askSimplifiedValueForOtherAAs(A))
return indicatePessimisticFixpoint();
// If a candicate was found in this update, return CHANGED.
@@ -4626,7 +4644,7 @@
};
if (!A.checkForAllReturnedValues(PredForReturned, *this))
- if (!askSimplifiedValueForAAValueConstantRange(A))
+ if (!askSimplifiedValueForOtherAAs(A))
return indicatePessimisticFixpoint();
// If a candicate was found in this update, return CHANGED.
@@ -4716,7 +4734,7 @@
if (!genericValueTraversal<AAValueSimplify, bool>(
A, getIRPosition(), *this, Dummy, VisitValueCB, getCtxI(),
/* UseValueSimplify */ false))
- if (!askSimplifiedValueForAAValueConstantRange(A))
+ if (!askSimplifiedValueForOtherAAs(A))
return indicatePessimisticFixpoint();
// If a candicate was found in this update, return CHANGED.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85632.284278.patch
Type: text/x-patch
Size: 3036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200810/26676544/attachment.bin>
More information about the llvm-commits
mailing list