diff options
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index c437a44..c7d758a 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -491,6 +491,16 @@ public: } Value *SCEVExpander::visitAddExpr(const SCEVAddExpr *S) { + // Recognize the canonical representation of an unsimplifed urem. + const SCEV *URemLHS = nullptr; + const SCEV *URemRHS = nullptr; + if (SE.matchURem(S, URemLHS, URemRHS)) { + Value *LHS = expand(URemLHS); + Value *RHS = expand(URemRHS); + return InsertBinop(Instruction::URem, LHS, RHS, SCEV::FlagAnyWrap, + /*IsSafeToHoist*/ false); + } + // Collect all the add operands in a loop, along with their associated loops. // Iterate in reverse so that constants are emitted last, all else equal, and // so that pointer operands are inserted first, which the code below relies on |