opt_expr: improve simplification of comparisons with large constants.
authorwhitequark <whitequark@whitequark.org>
Wed, 2 Jan 2019 05:04:28 +0000 (05:04 +0000)
committerwhitequark <whitequark@whitequark.org>
Wed, 2 Jan 2019 15:45:28 +0000 (15:45 +0000)
commitbf8db55ef36f6839827cd8bc69f673fd3fd43cca
tree4223f7318822ddd87ebb511a59d21d4d17de4faf
parent4fd458290c3da4c3f372f2e1fdd99829a9462a38
opt_expr: improve simplification of comparisons with large constants.

The idea behind this simplification is that a N-bit signal X being
compared with an M-bit constant where M>N and the constant has Nth
or higher bit set, it either always succeeds or always fails.

However, the existing implementation only worked with one-hot signals
for some reason. It also printed incorrect messages.

This commit adjusts the simplification to have as much power as
possible, and fixes other bugs.
passes/opt/opt_expr.cc
tests/opt/opt_expr_cmp.v