aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 9f33d2f..c457931 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3343,6 +3343,14 @@ Value *llvm::invertCondition(Value *Condition) {
if (I->getParent() == Parent && match(I, m_Not(m_Specific(Condition))))
return I;
+ // Fourth: Modify an existing instruction
+ if (Condition->hasOneUse()) {
+ if (auto *CI = dyn_cast<CmpInst>(Condition)) {
+ CI->setPredicate(CI->getInversePredicate());
+ return Condition;
+ }
+ }
+
// Last option: Create a new instruction
auto *Inverted =
BinaryOperator::CreateNot(Condition, Condition->getName() + ".inv");