mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
InstCombine: call FoldOpIntoSelect for all floating binops, not just fmul
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186759 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1186,9 +1186,15 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
|
||||
if (Value *V = SimplifyFAddInst(LHS, RHS, I.getFastMathFlags(), TD))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
if (isa<Constant>(RHS) && isa<PHINode>(LHS))
|
||||
if (Instruction *NV = FoldOpIntoPhi(I))
|
||||
return NV;
|
||||
if (isa<Constant>(RHS)) {
|
||||
if (isa<PHINode>(LHS))
|
||||
if (Instruction *NV = FoldOpIntoPhi(I))
|
||||
return NV;
|
||||
|
||||
if (SelectInst *SI = dyn_cast<SelectInst>(LHS))
|
||||
if (Instruction *NV = FoldOpIntoSelect(I, SI))
|
||||
return NV;
|
||||
}
|
||||
|
||||
// -A + B --> B - A
|
||||
// -A + -B --> -(A + B)
|
||||
@@ -1517,6 +1523,11 @@ Instruction *InstCombiner::visitFSub(BinaryOperator &I) {
|
||||
if (Value *V = SimplifyFSubInst(Op0, Op1, I.getFastMathFlags(), TD))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
if (isa<Constant>(Op0))
|
||||
if (SelectInst *SI = dyn_cast<SelectInst>(Op1))
|
||||
if (Instruction *NV = FoldOpIntoSelect(I, SI))
|
||||
return NV;
|
||||
|
||||
// If this is a 'B = x-(-A)', change to B = x+A...
|
||||
if (Value *V = dyn_castFNegVal(Op1))
|
||||
return BinaryOperator::CreateFAdd(Op0, V);
|
||||
|
||||
Reference in New Issue
Block a user