diff options
Diffstat (limited to 'llvm/lib/Transforms/Utils/SCCPSolver.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Utils/SCCPSolver.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp index 4225e7e80fda..81aa7ce1cfe6 100644 --- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp +++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp @@ -147,6 +147,16 @@ static bool refineInstruction(SCCPSolver &Solver, Changed = true; } } + } else if (auto *GEP = dyn_cast<GetElementPtrInst>(&Inst)) { + if (GEP->hasNoUnsignedWrap() || !GEP->hasNoUnsignedSignedWrap()) + return false; + + if (all_of(GEP->indices(), + [&](Value *V) { return GetRange(V).isAllNonNegative(); })) { + GEP->setNoWrapFlags(GEP->getNoWrapFlags() | + GEPNoWrapFlags::noUnsignedWrap()); + Changed = true; + } } return Changed; |
