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 | 163a84bbce69947aa314760e6068c704fc0df7a0 (patch) | |
tree | 4c45912de2fe18eee154b43593182969e3479ce7 /lib/Analysis/InstructionSimplify.cpp | |
parent | 1dbf0df996bba398a70abccc714b1a9652330014 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | lib/Analysis/InstructionSimplify.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index 7bb8f69992..2b217e1446 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/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; |