aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ConstraintSystem.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2020-09-15 13:50:11 +0100
committerFlorian Hahn <flo@fhahn.com>2020-09-15 13:50:11 +0100
commitdb22e70d010744573df19d69ed3de5b84ea60d1c (patch)
tree089e3303a4310697e91666b602d7198902ed98d1 /llvm/lib/Analysis/ConstraintSystem.cpp
parent98e07b5596c8692c43770bc4e21a2b19467e35f7 (diff)
downloadllvm-db22e70d010744573df19d69ed3de5b84ea60d1c.zip
llvm-db22e70d010744573df19d69ed3de5b84ea60d1c.tar.gz
llvm-db22e70d010744573df19d69ed3de5b84ea60d1c.tar.bz2
[ConstraintSolver] Add isConditionImplied helper.
This patch adds a isConditionImplied function that takes a constraint and returns true if the constraint is implied by the current constraints in the system. Reviewed By: spatel Differential Revision: https://reviews.llvm.org/D84545
Diffstat (limited to 'llvm/lib/Analysis/ConstraintSystem.cpp')
-rw-r--r--llvm/lib/Analysis/ConstraintSystem.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ConstraintSystem.cpp b/llvm/lib/Analysis/ConstraintSystem.cpp
index 21115fc..818cfe0 100644
--- a/llvm/lib/Analysis/ConstraintSystem.cpp
+++ b/llvm/lib/Analysis/ConstraintSystem.cpp
@@ -140,3 +140,13 @@ bool ConstraintSystem::mayHaveSolution() {
LLVM_DEBUG(dbgs() << (HasSolution ? "sat" : "unsat") << "\n");
return HasSolution;
}
+
+bool ConstraintSystem::isConditionImplied(SmallVector<int64_t, 8> R) {
+ // If there is no solution with the negation of R added to the system, the
+ // condition must hold based on the existing constraints.
+ R = ConstraintSystem::negate(R);
+
+ auto NewSystem = *this;
+ NewSystem.addVariableRow(R);
+ return !NewSystem.mayHaveSolution();
+}