diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/ConstraintElimination.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp index 2ae913c..251faa0 100644 --- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp +++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp @@ -57,6 +57,20 @@ static SmallVector<std::pair<int64_t, Value *>, 4> decompose(Value *V) { nullptr}, {1, GEP->getPointerOperand()}}; } + + Value *Op0; + Value *Op1; + ConstantInt *CI; + if (match(V, m_NUWAdd(m_Value(Op0), m_ConstantInt(CI)))) + return {{CI->getSExtValue(), nullptr}, {1, Op0}}; + if (match(V, m_NUWAdd(m_Value(Op0), m_Value(Op1)))) + return {{0, nullptr}, {1, Op0}, {1, Op1}}; + + if (match(V, m_NUWSub(m_Value(Op0), m_ConstantInt(CI)))) + return {{-1 * CI->getSExtValue(), nullptr}, {1, Op0}}; + if (match(V, m_NUWSub(m_Value(Op0), m_Value(Op1)))) + return {{0, nullptr}, {1, Op0}, {1, Op1}}; + return {{0, nullptr}, {1, V}}; } |
