diff options
author | Florian Hahn <flo@fhahn.com> | 2020-09-15 13:50:11 +0100 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2020-09-15 13:50:11 +0100 |
commit | db22e70d010744573df19d69ed3de5b84ea60d1c (patch) | |
tree | 089e3303a4310697e91666b602d7198902ed98d1 /llvm/lib/Analysis/ConstraintSystem.cpp | |
parent | 98e07b5596c8692c43770bc4e21a2b19467e35f7 (diff) | |
download | llvm-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.cpp | 10 |
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(); +} |