@@ -1822,6 +1822,17 @@ int OpInst::get_simple_version() {
1822
1822
1823
1823
void OpInst::propagate_uf () {
1824
1824
switch (m_op) {
1825
+ case Minus: {
1826
+ const InstL* ch = get_children ();
1827
+ if (ch->size () == 1 ) {
1828
+ InstL::const_iterator cit = ch->begin ();
1829
+ Inst* lhs = (*cit)->get_simple ();
1830
+ if (NumInst::as (lhs) && NumInst::as (lhs)->get_num () == 0 ) {
1831
+ // -0 = 0
1832
+ t_simple = lhs;
1833
+ }
1834
+ }
1835
+ } break ;
1825
1836
case Add: {
1826
1837
const InstL* ch = get_children ();
1827
1838
if (ch->size () == 2 ) {
@@ -1944,6 +1955,13 @@ void OpInst::propagate_uf() {
1944
1955
} else if (lhs == rhs) {
1945
1956
// x > x = false
1946
1957
t_simple = NumInst::create (0 , 1 , SORT ());
1958
+ } else if (NumInst::as (lhs) && NumInst::as (rhs)) {
1959
+ // both are numbers
1960
+ if (NumInst::as (lhs)->num_cmp (NumInst::as (rhs), false ) > 0 ) {
1961
+ t_simple = NumInst::create (1 , 1 , SORT ());
1962
+ } else {
1963
+ t_simple = NumInst::create (0 , 1 , SORT ());
1964
+ }
1947
1965
}
1948
1966
} break ;
1949
1967
case SGr: {
@@ -1956,6 +1974,15 @@ void OpInst::propagate_uf() {
1956
1974
if (lhs == rhs) {
1957
1975
// x >s x = false
1958
1976
t_simple = NumInst::create (0 , 1 , SORT ());
1977
+ } else if (NumInst::as (lhs) && NumInst::as (rhs)) {
1978
+ // both are numbers
1979
+ if (get_size () > 1 ) {
1980
+ if (NumInst::as (lhs)->num_cmp (NumInst::as (rhs), true ) > 0 ) {
1981
+ t_simple = NumInst::create (1 , 1 , SORT ());
1982
+ } else {
1983
+ t_simple = NumInst::create (0 , 1 , SORT ());
1984
+ }
1985
+ }
1959
1986
}
1960
1987
} break ;
1961
1988
case Le: {
@@ -1971,6 +1998,13 @@ void OpInst::propagate_uf() {
1971
1998
} else if (lhs == rhs) {
1972
1999
// x < x = false
1973
2000
t_simple = NumInst::create (0 , 1 , SORT ());
2001
+ } else if (NumInst::as (lhs) && NumInst::as (rhs)) {
2002
+ // both are numbers
2003
+ if (NumInst::as (lhs)->num_cmp (NumInst::as (rhs), false ) < 0 ) {
2004
+ t_simple = NumInst::create (1 , 1 , SORT ());
2005
+ } else {
2006
+ t_simple = NumInst::create (0 , 1 , SORT ());
2007
+ }
1974
2008
}
1975
2009
} break ;
1976
2010
case SLe: {
@@ -1983,6 +2017,15 @@ void OpInst::propagate_uf() {
1983
2017
if (lhs == rhs) {
1984
2018
// x <s x = false
1985
2019
t_simple = NumInst::create (0 , 1 , SORT ());
2020
+ } else if (NumInst::as (lhs) && NumInst::as (rhs)) {
2021
+ // both are numbers
2022
+ if (get_size () > 1 ) {
2023
+ if (NumInst::as (lhs)->num_cmp (NumInst::as (rhs), true ) < 0 ) {
2024
+ t_simple = NumInst::create (1 , 1 , SORT ());
2025
+ } else {
2026
+ t_simple = NumInst::create (0 , 1 , SORT ());
2027
+ }
2028
+ }
1986
2029
}
1987
2030
} break ;
1988
2031
case GrEq: {
@@ -1998,6 +2041,13 @@ void OpInst::propagate_uf() {
1998
2041
} else if (lhs == rhs) {
1999
2042
// x >= x = true
2000
2043
t_simple = NumInst::create (1 , 1 , SORT ());
2044
+ } else if (NumInst::as (lhs) && NumInst::as (rhs)) {
2045
+ // both are numbers
2046
+ if (NumInst::as (lhs)->num_cmp (NumInst::as (rhs), false ) >= 0 ) {
2047
+ t_simple = NumInst::create (1 , 1 , SORT ());
2048
+ } else {
2049
+ t_simple = NumInst::create (0 , 1 , SORT ());
2050
+ }
2001
2051
}
2002
2052
} break ;
2003
2053
case SGrEq: {
@@ -2010,6 +2060,15 @@ void OpInst::propagate_uf() {
2010
2060
if (lhs == rhs) {
2011
2061
// x >=s x = true
2012
2062
t_simple = NumInst::create (1 , 1 , SORT ());
2063
+ } else if (NumInst::as (lhs) && NumInst::as (rhs)) {
2064
+ // both are numbers
2065
+ if (get_size () > 1 ) {
2066
+ if (NumInst::as (lhs)->num_cmp (NumInst::as (rhs), true ) >= 0 ) {
2067
+ t_simple = NumInst::create (1 , 1 , SORT ());
2068
+ } else {
2069
+ t_simple = NumInst::create (0 , 1 , SORT ());
2070
+ }
2071
+ }
2013
2072
}
2014
2073
} break ;
2015
2074
case LeEq: {
@@ -2025,6 +2084,13 @@ void OpInst::propagate_uf() {
2025
2084
} else if (lhs == rhs) {
2026
2085
// x <= x = true
2027
2086
t_simple = NumInst::create (1 , 1 , SORT ());
2087
+ } else if (NumInst::as (lhs) && NumInst::as (rhs)) {
2088
+ // both are numbers
2089
+ if (NumInst::as (lhs)->num_cmp (NumInst::as (rhs), false ) <= 0 ) {
2090
+ t_simple = NumInst::create (1 , 1 , SORT ());
2091
+ } else {
2092
+ t_simple = NumInst::create (0 , 1 , SORT ());
2093
+ }
2028
2094
}
2029
2095
} break ;
2030
2096
case SLeEq: {
@@ -2037,7 +2103,16 @@ void OpInst::propagate_uf() {
2037
2103
if (lhs == rhs) {
2038
2104
// x <=s x = true
2039
2105
t_simple = NumInst::create (1 , 1 , SORT ());
2040
- }
2106
+ } else if (NumInst::as (lhs) && NumInst::as (rhs)) {
2107
+ // both are numbers
2108
+ if (get_size () > 1 ) {
2109
+ if (NumInst::as (lhs)->num_cmp (NumInst::as (rhs), true ) <= 0 ) {
2110
+ t_simple = NumInst::create (1 , 1 , SORT ());
2111
+ } else {
2112
+ t_simple = NumInst::create (0 , 1 , SORT ());
2113
+ }
2114
+ }
2115
+ }
2041
2116
} break ;
2042
2117
case BitWiseAnd: {
2043
2118
const InstL* ch = get_children ();
@@ -2142,9 +2217,9 @@ void OpInst::propagate_uf() {
2142
2217
;
2143
2218
}
2144
2219
2145
- // if (this != this->get_simple()) {
2146
- // cout << "uf_prop: " << *this << " -> " << *(this->t_simple) << endl;
2147
- // }
2220
+ if (this != this ->get_simple ()) {
2221
+ cout << " uf_prop: " << *this << " -> " << *(this ->t_simple ) << endl;
2222
+ }
2148
2223
}
2149
2224
2150
2225
bool OpInst::is_heavy_uf () {
0 commit comments