Skip to content
Snippets Groups Projects
Commit 66ef40f9 authored by Alessandro Di Federico's avatar Alessandro Di Federico
Browse files

Rewrite `OSRA::handleComparison`

`OSRA:handleComparison` was too big and complex, it has been mostly
rewritten.

* Create `OSRA::identifyComparisonOperands` which expands the argument
  of the comparison in a list of possible values (constants or
  OSRs). The new way in which we handle possible operands also fixes a
  bug showing up in case a constant OSR was being compared with an LLVM
  constant, which was checked for being a tautology/contradiction,
  preventing the reaching definitions of the operand to be considered
  too.
* Squeeze more information from uge/ugt. Unsigned comparisons lead to
  two pieces information: the result of the comparison itself, and the
  fact the left-hand side is greather than or equal 0. This secondo
  information is precious, but we were not able to exploit it in the
  case the original comparison is already "greater than" or "greater
  than or equal". In fact, `x - 4 > 10` gives us `x >= 4` and `x > 14`,
  which boils down to `x > 14`.  This commit introduces a change that
  handles this case as `NOT x - 4 <= 10` leading to the negation of `x
  >= 4` and `x < 14` which is way more informative.
* Improve `OSRA::mergePredicate` and `OSRA::applyConstraints`
  interfaces.
* In case a comparison instructions leads to multiple constraints on the
  same `Value`, these constraints are now first or-merged together and
  then propagated. This change improves the quality of the analysis in
  certain situations.
parent 5b8fb1af
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment