diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-06-24 21:27:36 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-06-24 21:27:36 +0000 |
commit | f6e500a0dca4c16799deca466481b4a1e9cbcdbd (patch) | |
tree | 92c40becdd5cf20f04f316dcce952247b2bde5d7 /llvm/lib/Transforms/Scalar/Reassociate.cpp | |
parent | 64ea207027a7dee2b7fb1bfb85df8e4ac46f3a67 (diff) | |
download | bcm5719-llvm-f6e500a0dca4c16799deca466481b4a1e9cbcdbd.tar.gz bcm5719-llvm-f6e500a0dca4c16799deca466481b4a1e9cbcdbd.zip |
[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.
llvm-svn: 240593
Diffstat (limited to 'llvm/lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/Reassociate.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index 6c66b58729e..d1acf785d07 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -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; } |