Commit Graph

6 Commits

Author SHA1 Message Date
Valentina Sona 8429c35f2e Insert boolean not on equal to zero comparisons
Implements the transformation (x == 0) -> (!x) via the boolean not
opcode, inside the two's complement arithmetic normalization pass.
2023-06-12 14:17:34 +02:00
Pietro Fezzardi f4020c9fa6 TNAP: fix handling of wraparounds
Before this commit, the TwosComplementArithmeticNormalizationPass wasn't
taking into consideration properly all the cases where the arithmetic
can wrap around in case of expression such as (x + const1 <=> const2) or
(x - const1 <=> const 2).

This caused 2 different classes of problems that affected semantics.
1) In some cases we were emitting comparisons that were too broad,
   meaning that they were true in a larger set of cases than the
   original one.
2) In other cases we were emitting tautological comparisons, i.e.
   comparisons that were always demonstrably true or false at compile
   time.

This commit fixes the problem, treating all the cases in a generalized
unique way that works correctly for every case.
2023-06-09 09:24:52 +02:00
Valentina Sona 0e61bf3fd2 TANP: Move constants to right side of comparisons
Implements transforms when the results of sub or add with a constant
operand are compared against constant:
1) x + a == b --> x == b - a
2) x + a != b --> x != b - a
3) x + a <= b --> x <= b - a
4) x + a < b --> x < b - a
5) x + a >= b --> x >= b - a
6) x + a > b --> x > b - a

After the transformation, the right hand side is also enqued for
analysis to detect opporunities to use unary minus if a-b is a negative
constant.
2023-05-12 15:21:22 +02:00
Kacper Kołodziej 568bd24900 Add UnaryMinus and BinaryNot 2023-01-09 15:01:16 +01:00
Giacomo Vercesi ab125b35b0 Fix License headers
Change company name to "rev.ng Labs Srl" in all license headers
to reflect changed company name and legal status
Add missing license headers to files that didn't have one
2022-04-19 12:17:59 +02:00
Antonio Frighetto 212816753a Introduce TwosComplementArithmeticNormalizationPass 2022-02-03 20:12:23 +01:00