Add some statistics, good for understanding how much more powerful
instcombine is compared to instsimplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122397 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp
index c679ef4..84d85b7 100644
--- a/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -58,6 +58,8 @@
STATISTIC(NumConstProp, "Number of constant folds");
STATISTIC(NumDeadInst , "Number of dead inst eliminated");
STATISTIC(NumSunkInst , "Number of instructions sunk");
+STATISTIC(NumFactor , "Number of factorizations");
+STATISTIC(NumReassoc , "Number of reassociations");
// Initialization Routines
void llvm::initializeInstCombine(PassRegistry &Registry) {
@@ -155,6 +157,7 @@
I.setOperand(0, A);
I.setOperand(1, V);
Changed = true;
+ ++NumReassoc;
continue;
}
}
@@ -171,6 +174,7 @@
I.setOperand(0, V);
I.setOperand(1, C);
Changed = true;
+ ++NumReassoc;
continue;
}
}
@@ -189,6 +193,7 @@
I.setOperand(0, V);
I.setOperand(1, B);
Changed = true;
+ ++NumReassoc;
continue;
}
}
@@ -205,6 +210,7 @@
I.setOperand(0, B);
I.setOperand(1, V);
Changed = true;
+ ++NumReassoc;
continue;
}
}
@@ -321,8 +327,10 @@
// operations "A op' B" and "C op' D" will be zapped since no longer used.
if (!RHS && Op0->hasOneUse() && Op1->hasOneUse())
RHS = Builder->CreateBinOp(OuterOpcode, B, D, Op1->getName());
- if (RHS)
+ if (RHS) {
+ ++NumFactor;
return BinaryOperator::Create(InnerOpcode, A, RHS);
+ }
}
// Does "(X op Y) op' Z" always equal "(X op' Z) op (Y op' Z)"?
@@ -339,8 +347,10 @@
// operations "A op' B" and "C op' D" will be zapped since no longer used.
if (!LHS && Op0->hasOneUse() && Op1->hasOneUse())
LHS = Builder->CreateBinOp(OuterOpcode, A, C, Op0->getName());
- if (LHS)
+ if (LHS) {
+ ++NumFactor;
return BinaryOperator::Create(InnerOpcode, LHS, B);
+ }
}
return 0;