diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2024-11-21 12:55:29 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2024-11-21 12:55:29 +0000 |
| commit | f65bf063bcac0dcdca7d3b7b865e29c837566543 (patch) | |
| tree | 2b5bd79e99c9aeed4082427ad8ae0f70b8852d6c /llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp | |
| parent | efdccd8358633400f927c74be0f7969bda1b3775 (diff) | |
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp index e4895b59f4b4..cb052da79bb3 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp @@ -334,6 +334,17 @@ std::array<Value *, 2> Negator::getSortedOperandsOfBinOp(Instruction *I) { NewSelect->swapValues(); // Don't swap prof metadata, we didn't change the branch behavior. NewSelect->setName(I->getName() + ".neg"); + // Poison-generating flags should be dropped + Value *TV = NewSelect->getTrueValue(); + Value *FV = NewSelect->getFalseValue(); + if (match(TV, m_Neg(m_Specific(FV)))) + cast<Instruction>(TV)->dropPoisonGeneratingFlags(); + else if (match(FV, m_Neg(m_Specific(TV)))) + cast<Instruction>(FV)->dropPoisonGeneratingFlags(); + else { + cast<Instruction>(TV)->dropPoisonGeneratingFlags(); + cast<Instruction>(FV)->dropPoisonGeneratingFlags(); + } Builder.Insert(NewSelect); return NewSelect; } |
