diff options
author | Florian Hahn <flo@fhahn.com> | 2020-12-05 10:52:50 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2020-12-05 12:06:53 +0000 |
commit | 4ceecc820b7197c2f302aa235875eb6619a397c3 (patch) | |
tree | 3241f55f5f328782a7b1a6ac38c60e955492f479 /llvm/lib/Analysis/ConstraintSystem.cpp | |
parent | a0b3a9391cd8cfff2ad1741f12e5ed10acc97869 (diff) | |
download | llvm-4ceecc820b7197c2f302aa235875eb6619a397c3.zip llvm-4ceecc820b7197c2f302aa235875eb6619a397c3.tar.gz llvm-4ceecc820b7197c2f302aa235875eb6619a397c3.tar.bz2 |
[ConstraintElimination] Handle constraints with all zero var coeffs.
Constraints where all variable coefficients are 0 do not add any useful
information. When checking, we can check if they are always true/false.
Diffstat (limited to 'llvm/lib/Analysis/ConstraintSystem.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstraintSystem.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ConstraintSystem.cpp b/llvm/lib/Analysis/ConstraintSystem.cpp index d5b15e7..3df1184 100644 --- a/llvm/lib/Analysis/ConstraintSystem.cpp +++ b/llvm/lib/Analysis/ConstraintSystem.cpp @@ -140,6 +140,11 @@ bool ConstraintSystem::mayHaveSolution() { } bool ConstraintSystem::isConditionImplied(SmallVector<int64_t, 8> R) { + // If all variable coefficients are 0, we have 'C >= 0'. If the constant is >= + // 0, R is always true, regardless of the system. + if (all_of(makeArrayRef(R).drop_front(1), [](int64_t C) { return C == 0; })) + return R[0] >= 0; + // 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); |