mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-22 07:24:47 +00:00
[Reassociate] Don't propogate flags when creating negations
Reassociate mutated existing instructions in order to form negations which would create additional reassociate opportunities. This fixes PR23926. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240593 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -936,6 +936,10 @@ static Value *NegateValue(Value *V, Instruction *BI) {
|
||||
// Push the negates through the add.
|
||||
I->setOperand(0, NegateValue(I->getOperand(0), BI));
|
||||
I->setOperand(1, NegateValue(I->getOperand(1), BI));
|
||||
if (I->getOpcode() == Instruction::Add) {
|
||||
I->setHasNoUnsignedWrap(false);
|
||||
I->setHasNoSignedWrap(false);
|
||||
}
|
||||
|
||||
// We must move the add instruction here, because the neg instructions do
|
||||
// not dominate the old add instruction in general. By moving it, we are
|
||||
@@ -976,6 +980,12 @@ static Value *NegateValue(Value *V, Instruction *BI) {
|
||||
InsertPt = TheNeg->getParent()->getParent()->getEntryBlock().begin();
|
||||
}
|
||||
TheNeg->moveBefore(InsertPt);
|
||||
if (TheNeg->getOpcode() == Instruction::Sub) {
|
||||
TheNeg->setHasNoUnsignedWrap(false);
|
||||
TheNeg->setHasNoSignedWrap(false);
|
||||
} else {
|
||||
TheNeg->andIRFlags(BI);
|
||||
}
|
||||
return TheNeg;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user