Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp =================================================================== --- llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -4474,23 +4474,34 @@ return true; } - bool askSimplifiedValueForAAValueConstantRange(Attributor &A) { + /// Returns a candidate is found or not + template bool askSimplifiedValueFor(Attributor &A) { if (!getAssociatedValue().getType()->isIntegerTy()) return false; - const auto &ValueConstantRangeAA = - A.getAAFor(*this, getIRPosition()); + const auto &AA = + A.getAAFor(*this, getIRPosition(), /* TrackDependence */ true, + DepClassTy::OPTIONAL); - Optional COpt = - ValueConstantRangeAA.getAssumedConstantInt(A); - if (COpt.hasValue()) { - if (auto *C = COpt.getValue()) + Optional COpt = AA.getAssumedConstantInt(A); + + if (!COpt.hasValue()) { + SimplifiedAssociatedValue = llvm::None; + return true; + } else { + if (auto *C = COpt.getValue()) { SimplifiedAssociatedValue = C; - else + return true; + } else { return false; - } else { - SimplifiedAssociatedValue = llvm::None; + } } + } + + bool askSimplifiedValueForOtherAAs(Attributor &A) { + if (!askSimplifiedValueFor(A)) + if (!askSimplifiedValueFor(A)) + return false; return true; } @@ -4598,7 +4609,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 +4637,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 +4727,7 @@ if (!genericValueTraversal( 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.