diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:01:25 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:01:25 +0000 | 
| commit | d8e91e46262bc44006913e6796843909f1ac7bcd (patch) | |
| tree | 7d0c143d9b38190e0fa0180805389da22cd834c5 /lib/Transforms/Utils/SimplifyIndVar.cpp | |
| parent | b7eb8e35e481a74962664b63dfb09483b200209a (diff) | |
Notes
Diffstat (limited to 'lib/Transforms/Utils/SimplifyIndVar.cpp')
| -rw-r--r-- | lib/Transforms/Utils/SimplifyIndVar.cpp | 11 | 
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/SimplifyIndVar.cpp b/lib/Transforms/Utils/SimplifyIndVar.cpp index 65b23f4d94a1..7faf291e73d9 100644 --- a/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -106,8 +106,9 @@ namespace {  /// Otherwise return null.  Value *SimplifyIndvar::foldIVUser(Instruction *UseInst, Instruction *IVOperand) {    Value *IVSrc = nullptr; -  unsigned OperIdx = 0; +  const unsigned OperIdx = 0;    const SCEV *FoldedExpr = nullptr; +  bool MustDropExactFlag = false;    switch (UseInst->getOpcode()) {    default:      return nullptr; @@ -140,6 +141,11 @@ Value *SimplifyIndvar::foldIVUser(Instruction *UseInst, Instruction *IVOperand)                             APInt::getOneBitSet(BitWidth, D->getZExtValue()));      }      FoldedExpr = SE->getUDivExpr(SE->getSCEV(IVSrc), SE->getSCEV(D)); +    // We might have 'exact' flag set at this point which will no longer be +    // correct after we make the replacement. +    if (UseInst->isExact() && +        SE->getSCEV(IVSrc) != SE->getMulExpr(FoldedExpr, SE->getSCEV(D))) +      MustDropExactFlag = true;    }    // We have something that might fold it's operand. Compare SCEVs.    if (!SE->isSCEVable(UseInst->getType())) @@ -155,6 +161,9 @@ Value *SimplifyIndvar::foldIVUser(Instruction *UseInst, Instruction *IVOperand)    UseInst->setOperand(OperIdx, IVSrc);    assert(SE->getSCEV(UseInst) == FoldedExpr && "bad SCEV with folded oper"); +  if (MustDropExactFlag) +    UseInst->dropPoisonGeneratingFlags(); +    ++NumElimOperand;    Changed = true;    if (IVOperand->use_empty())  | 
