diff options
author | Duncan Sands <baldrick@free.fr> | 2011-02-07 09:36:32 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2011-02-07 09:36:32 +0000 |
commit | 867cb633b428b0017ea8ecf548176ae6000fcef2 (patch) | |
tree | a7f475d64e5a8c1f13a9ccb28668c1eb9045057f /llvm/lib/Analysis/InstructionSimplify.cpp | |
parent | 648f55b2b435cd05085c0af5ae9ab27e0c5a3047 (diff) | |
download | bcm5719-llvm-867cb633b428b0017ea8ecf548176ae6000fcef2.tar.gz bcm5719-llvm-867cb633b428b0017ea8ecf548176ae6000fcef2.zip |
Add an m_Div pattern for matching either a udiv or an sdiv and use it
to simplify the "(X/Y)*Y->X when the division is exact" transform.
llvm-svn: 125004
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 7bb8f699928..2b217e14468 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -734,10 +734,8 @@ 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(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)) { + if ((match(Op0, m_Div(m_Value(X), m_Value(Y))) && Y == Op1) || // (X / Y) * Y + (match(Op1, m_Div(m_Value(X), m_Value(Y))) && Y == Op0)) { // Y * (X / Y) BinaryOperator *Div = cast<BinaryOperator>(Y == Op1 ? Op0 : Op1); if (Div->isExact()) return X; |