// getComplexity: Assign a complexity or rank value to LLVM Values...
// 0 -> undef, 1 -> Const, 2 -> Other, 3 -> Arg, 3 -> Unary, 4 -> OtherInst
-static unsigned getComplexity(LLVMContext *Context, Value *V) {
+static unsigned getComplexity(Value *V) {
if (isa<Instruction>(V)) {
if (BinaryOperator::isNeg(V) ||
BinaryOperator::isFNeg(V) ||
//
bool InstCombiner::SimplifyCommutative(BinaryOperator &I) {
bool Changed = false;
- if (getComplexity(Context, I.getOperand(0)) <
- getComplexity(Context, I.getOperand(1)))
+ if (getComplexity(I.getOperand(0)) < getComplexity(I.getOperand(1)))
Changed = !I.swapOperands();
if (!I.isAssociative()) return Changed;
/// so that theyare listed from right (least complex) to left (most complex).
/// This puts constants before unary operators before binary operators.
bool InstCombiner::SimplifyCompare(CmpInst &I) {
- if (getComplexity(Context, I.getOperand(0)) >=
- getComplexity(Context, I.getOperand(1)))
+ if (getComplexity(I.getOperand(0)) >= getComplexity(I.getOperand(1)))
return false;
I.swapOperands();
// Compare instructions are not associative so there's nothing else we can do.