[llvm-commits] [llvm] r123517 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
Chris Lattner
sabre at nondot.org
Fri Jan 14 21:50:18 PST 2011
Author: lattner
Date: Fri Jan 14 23:50:18 2011
New Revision: 123517
URL: http://llvm.org/viewvc/llvm-project?rev=123517&view=rev
Log:
one more instcombine variant that is needed to work with future changes,
no functionality change currently.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=123517&r1=123516&r2=123517&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp Fri Jan 14 23:50:18 2011
@@ -672,6 +672,15 @@
Value *NewMul = Builder->CreateMul(A, B);
return BinaryOperator::CreateAdd(Op0, NewMul);
}
+
+ // X - A*Cst -> X + A*-Cst
+ // X - Cst*A -> X + A*-Cst
+ ConstantInt *BCst;
+ if (match(Op1I, m_Mul(m_Value(A), m_ConstantInt(BCst))) ||
+ match(Op1I, m_Mul(m_ConstantInt(BCst), m_Value(A)))) {
+ Value *NewMul = Builder->CreateMul(A, ConstantExpr::getNeg(BCst));
+ return BinaryOperator::CreateAdd(Op0, NewMul);
+ }
}
}
More information about the llvm-commits
mailing list