diff options
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/InstructionSimplify.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index 220868fe1d..7bb8f69992 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -735,9 +735,11 @@ static Value *SimplifyMulInst(Value *Op0, Value *Op1, const TargetData *TD, // (X / Y) * Y -> X if the division is exact. Value *X = 0, *Y = 0; if ((match(Op0, m_SDiv(m_Value(X), m_Value(Y))) && Y == Op1) || // (X / Y) * Y - (match(Op1, m_SDiv(m_Value(X), m_Value(Y))) && Y == Op0)) { // Y * (X / Y) - BinaryOperator *SDiv = cast<BinaryOperator>(Y == Op1 ? Op0 : Op1); - if (SDiv->isExact()) + (match(Op0, m_UDiv(m_Value(X), m_Value(Y))) && Y == Op1) || + (match(Op1, m_SDiv(m_Value(X), m_Value(Y))) && Y == Op0) || // Y * (X / Y) + (match(Op1, m_UDiv(m_Value(X), m_Value(Y))) && Y == Op0)) { + BinaryOperator *Div = cast<BinaryOperator>(Y == Op1 ? Op0 : Op1); + if (Div->isExact()) return X; } |