mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-02 22:23:10 +00:00
Split up subtracts into add+negate if they have a reassociable use or operand
that is also a subtract. This implements PR2047 and Transforms/Reassociate/subtest2.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47241 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -399,13 +399,16 @@ static bool ShouldBreakUpSubtract(Instruction *Sub) {
|
||||
return false;
|
||||
|
||||
// Don't bother to break this up unless either the LHS is an associable add or
|
||||
// if this is only used by one.
|
||||
if (isReassociableOp(Sub->getOperand(0), Instruction::Add))
|
||||
// subtract or if this is only used by one.
|
||||
if (isReassociableOp(Sub->getOperand(0), Instruction::Add) ||
|
||||
isReassociableOp(Sub->getOperand(0), Instruction::Sub))
|
||||
return true;
|
||||
if (isReassociableOp(Sub->getOperand(1), Instruction::Add))
|
||||
if (isReassociableOp(Sub->getOperand(1), Instruction::Add) ||
|
||||
isReassociableOp(Sub->getOperand(0), Instruction::Sub))
|
||||
return true;
|
||||
|
||||
if (Sub->hasOneUse() && isReassociableOp(Sub->use_back(), Instruction::Add))
|
||||
if (Sub->hasOneUse() &&
|
||||
(isReassociableOp(Sub->use_back(), Instruction::Add) ||
|
||||
isReassociableOp(Sub->use_back(), Instruction::Sub)))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user