diff options
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index e71ba5e..759c553 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -929,12 +929,11 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP, if (!AllConstantInt) break; - // TODO: Try to intersect two inrange attributes? - if (!InRange) { - InRange = GEP->getInRange(); - if (InRange) - // Adjust inrange by offset until now. - InRange = InRange->sextOrTrunc(BitWidth).subtract(Offset); + // Adjust inrange offset and intersect inrange attributes + if (auto GEPRange = GEP->getInRange()) { + auto AdjustedGEPRange = GEPRange->sextOrTrunc(BitWidth).subtract(Offset); + InRange = + InRange ? InRange->intersectWith(AdjustedGEPRange) : AdjustedGEPRange; } Ptr = cast<Constant>(GEP->getOperand(0)); @@ -2004,21 +2003,20 @@ inline bool llvm_fenv_testexcept() { return false; } -static const APFloat FTZPreserveSign(const APFloat &V) { +static APFloat FTZPreserveSign(const APFloat &V) { if (V.isDenormal()) return APFloat::getZero(V.getSemantics(), V.isNegative()); return V; } -static const APFloat FlushToPositiveZero(const APFloat &V) { +static APFloat FlushToPositiveZero(const APFloat &V) { if (V.isDenormal()) return APFloat::getZero(V.getSemantics(), false); return V; } -static const APFloat -FlushWithDenormKind(const APFloat &V, - DenormalMode::DenormalModeKind DenormKind) { +static APFloat FlushWithDenormKind(const APFloat &V, + DenormalMode::DenormalModeKind DenormKind) { assert(DenormKind != DenormalMode::DenormalModeKind::Invalid && DenormKind != DenormalMode::DenormalModeKind::Dynamic); switch (DenormKind) { |