Remove redunant optimizations from InstCombine, instead call the appropriate functions from SimplifyInstruction

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169941 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael Ilseman
2012-12-12 00:28:32 +00:00
parent 09ee250e72
commit c244f38176
2 changed files with 9 additions and 30 deletions
@@ -296,20 +296,11 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
bool Changed = SimplifyAssociativeOrCommutative(I);
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
// Simplify mul instructions with a constant RHS.
if (Constant *Op1C = dyn_cast<Constant>(Op1)) {
if (ConstantFP *Op1F = dyn_cast<ConstantFP>(Op1C)) {
// "In IEEE floating point, x*1 is not equivalent to x for nans. However,
// ANSI says we can drop signals, so we can do this anyway." (from GCC)
if (Op1F->isExactlyValue(1.0))
return ReplaceInstUsesWith(I, Op0); // Eliminate 'fmul double %X, 1.0'
} else if (ConstantDataVector *Op1V = dyn_cast<ConstantDataVector>(Op1C)) {
// As above, vector X*splat(1.0) -> X in all defined cases.
if (ConstantFP *F = dyn_cast_or_null<ConstantFP>(Op1V->getSplatValue()))
if (F->isExactlyValue(1.0))
return ReplaceInstUsesWith(I, Op0);
}
if (Value *V = SimplifyFMulInst(Op0, Op1, I.getFastMathFlags(), TD))
return ReplaceInstUsesWith(I, V);
// Simplify mul instructions with a constant RHS.
if (isa<Constant>(Op1)) {
// Try to fold constant mul into select arguments.
if (SelectInst *SI = dyn_cast<SelectInst>(Op0))
if (Instruction *R = FoldOpIntoSelect(I, SI))