| 1 |
add_reassoc_consts: int_add(int_add(x, C1), C2) |
| 2 |
C = C1 + C2 |
| 3 |
=> int_add(x, C) |
| 4 |
|
| 5 |
add_zero: int_add(x, 0) |
| 6 |
=> x |
| 7 |
|
| 8 |
#add_self: int_add(x, x) |
| 9 |
# => int_mul(x, 2) |
| 10 |
|
| 11 |
add_sub_x_c_c: int_add(int_sub(x, C1), C2) |
| 12 |
C = C2 - C1 |
| 13 |
=> int_add(x, C) |
| 14 |
|
| 15 |
add_sub_c_x_c: int_add(int_sub(C1, x), C2) |
| 16 |
C = C1 + C2 |
| 17 |
=> int_sub(C, x) |
| 18 |
|
| 19 |
#add_sub: int_add(int_sub(x, y), y) |
| 20 |
# => x |
| 21 |
# |
| 22 |
#add_neg: int_add(int_neg(x), y) |
| 23 |
# => int_sub(y, x) |
| 24 |
# |
| 25 |
|
| 26 |
sub_zero: int_sub(x, 0) |
| 27 |
=> x |
| 28 |
|
| 29 |
sub_from_zero: int_sub(0, x) |
| 30 |
=> int_neg(x) |
| 31 |
|
| 32 |
sub_x_x: int_sub(x, x) |
| 33 |
=> 0 |
| 34 |
|
| 35 |
sub_add_consts: int_sub(int_add(x, C1), C2) |
| 36 |
C = C2 - C1 |
| 37 |
=> int_sub(x, C) |
| 38 |
|
| 39 |
sub_add: int_sub(int_add(x, y), y) |
| 40 |
=> x |
| 41 |
|
| 42 |
sub_add_neg: int_sub(y, int_add(x, y)) |
| 43 |
=> int_neg(x) |
| 44 |
|
| 45 |
sub_sub_left_x_c_c: int_sub(int_sub(x, C1), C2) |
| 46 |
C = C1 + C2 |
| 47 |
=> int_sub(x, C) |
| 48 |
|
| 49 |
sub_sub_left_c_x_c: int_sub(int_sub(C1, x), C2) |
| 50 |
C = C1 - C2 |
| 51 |
=> int_sub(C, x) |
| 52 |
|
| 53 |
#sub_sub_right_c_x_c: int_sub(C1, int_sub(x, C2)) |
| 54 |
# C = C1 + C2 |
| 55 |
# => int_sub(C, x) |
| 56 |
# |
| 57 |
#sub_sub_right_c_c_x: int_sub(C1, int_sub(C2, x)) |
| 58 |
# C = C1 - C2 |
| 59 |
# => int_add(C, x) |
| 60 |
|
| 61 |
sub_xor_x_y_y: int_sub(int_xor(x, y), y) |
| 62 |
# (x ^ y) - y == x if x & y == 0 |
| 63 |
# because `(x + y) = (x ^ y) + (x & y) * 2` |
| 64 |
check x.and_bound(y).known_eq_const(0) |
| 65 |
=> x |
| 66 |
|
| 67 |
sub_or_x_y_y: int_sub(int_or(x, y), y) |
| 68 |
# (x | y) - y == x if x & y == 0 |
| 69 |
# because `(x + y) = (x ^ y) + (x & y) * 2` |
| 70 |
# and because (x | y) = (x ^ y) + (x & y) |
| 71 |
check x.and_bound(y).known_eq_const(0) |
| 72 |
=> x |
| 73 |
|
| 74 |
sub_invert_one: int_sub(int_invert(x), -1) |
| 75 |
# useful for int_abs(known-negative-value) |
| 76 |
=> int_neg(x) |
| 77 |
|
| 78 |
#sub_neg: int_sub(x, int_neg(y)) |
| 79 |
# => int_add(x, y) |
| 80 |
|
| 81 |
|
| 82 |
mul_zero: int_mul(x, 0) |
| 83 |
=> 0 |
| 84 |
|
| 85 |
mul_one: int_mul(x, 1) |
| 86 |
=> x |
| 87 |
|
| 88 |
mul_minus_one: int_mul(x, -1) |
| 89 |
=> int_neg(x) |
| 90 |
|
| 91 |
mul_pow2_const: int_mul(x, C) |
| 92 |
check C > 0 and C & (C - 1) == 0 |
| 93 |
shift = highest_bit(C) |
| 94 |
=> int_lshift(x, shift) |
| 95 |
|
| 96 |
mul_lshift: int_mul(x, int_lshift(1, y)) |
| 97 |
check y.known_ge_const(0) and y.known_le_const(LONG_BIT) |
| 98 |
=> int_lshift(x, y) |
| 99 |
|
| 100 |
#mul_neg_neg: int_mul(int_neg(x), int_neg(y)) |
| 101 |
# => int_mul(x, y) |
| 102 |
|
| 103 |
|
| 104 |
and_x_x: int_and(a, a) |
| 105 |
=> a |
| 106 |
|
| 107 |
and_reassoc_consts: int_and(int_and(x, C1), C2) |
| 108 |
C = C1 & C2 |
| 109 |
=> int_and(x, C) |
| 110 |
|
| 111 |
and_x_c_in_range: int_and(x, C) |
| 112 |
check x.lower >= 0 and x.upper <= C & ~(C + 1) |
| 113 |
=> x |
| 114 |
|
| 115 |
and_idempotent: int_and(x, y) |
| 116 |
# int_and(x, y) == x if the 1s in y cover all 1s and all ?s in x |
| 117 |
check y.ones | x.zeros == -1 |
| 118 |
=> x |
| 119 |
|
| 120 |
and_or: int_and(int_or(x, y), z) |
| 121 |
check y.and_bound(z).known_eq_const(0) |
| 122 |
=> int_and(x, z) |
| 123 |
|
| 124 |
#and_add: int_and(int_add(x, y), z) |
| 125 |
# check y.and_bound(z).known_eq_const(0) |
| 126 |
# => int_and(x, z) |
| 127 |
|
| 128 |
and_known_result: int_and(a, b) |
| 129 |
bound = a.and_bound(b) |
| 130 |
check bound.is_constant() |
| 131 |
C = bound.get_constant_int() |
| 132 |
=> C |
| 133 |
|
| 134 |
and_absorb: int_and(a, int_and(a, b)) |
| 135 |
=> int_and(a, b) # XXX reuse the inner op |
| 136 |
|
| 137 |
|
| 138 |
or_x_x: int_or(a, a) |
| 139 |
=> a |
| 140 |
|
| 141 |
or_known_result: int_or(a, b) |
| 142 |
bound = a.or_bound(b) |
| 143 |
check bound.is_constant() |
| 144 |
C = bound.get_constant_int() |
| 145 |
=> C |
| 146 |
|
| 147 |
or_absorb: int_or(a, int_or(a, b)) |
| 148 |
=> int_or(a, b) |
| 149 |
|
| 150 |
or_idempotent: int_or(x, y) |
| 151 |
# int_or(x, y) == x if the 0s in y cover all 0s and all ?s in x |
| 152 |
check x.ones | y.zeros == -1 |
| 153 |
=> x |
| 154 |
|
| 155 |
or_and_two_parts: int_or(int_and(x, C1), int_and(x, C2)) |
| 156 |
C = C1 | C2 |
| 157 |
=> int_and(x, C) |
| 158 |
|
| 159 |
or_reassoc_consts: int_or(int_or(x, C1), C2) |
| 160 |
C = C1 | C2 |
| 161 |
=> int_or(x, C) |
| 162 |
|
| 163 |
xor_x_x: int_xor(a, a) |
| 164 |
=> 0 |
| 165 |
|
| 166 |
xor_reassoc_consts: int_xor(int_xor(x, C1), C2) |
| 167 |
C = C1 ^ C2 |
| 168 |
=> int_xor(x, C) |
| 169 |
|
| 170 |
xor_absorb: int_xor(int_xor(a, b), b) |
| 171 |
=> a |
| 172 |
|
| 173 |
xor_zero: int_xor(a, 0) |
| 174 |
=> a |
| 175 |
|
| 176 |
xor_minus_1: int_xor(x, -1) |
| 177 |
=> int_invert(x) |
| 178 |
|
| 179 |
xor_known_result: int_xor(C1, C2) |
| 180 |
C = C1 ^ C2 |
| 181 |
=> C |
| 182 |
|
| 183 |
xor_is_not: int_xor(x, 1) |
| 184 |
check x.is_bool() |
| 185 |
=> int_is_zero(x) |
| 186 |
|
| 187 |
|
| 188 |
lshift_zero_x: int_lshift(0, x) |
| 189 |
=> 0 |
| 190 |
|
| 191 |
lshift_x_zero: int_lshift(x, 0) |
| 192 |
=> x |
| 193 |
|
| 194 |
lshift_rshift_c_c: int_lshift(int_rshift(x, C1), C1) |
| 195 |
check 0 <= C1 and C1 < LONG_BIT |
| 196 |
C = -1 << C1 |
| 197 |
=> int_and(x, C) |
| 198 |
|
| 199 |
lshift_and_rshift: int_lshift(int_and(int_rshift(x, C1), C2), C1) |
| 200 |
check 0 <= C1 and C1 < LONG_BIT |
| 201 |
C = C2 << C1 |
| 202 |
=> int_and(x, C) |
| 203 |
|
| 204 |
lshift_urshift_c_c: int_lshift(uint_rshift(x, C1), C1) |
| 205 |
check 0 <= C1 and C1 < LONG_BIT |
| 206 |
C = -1 << C1 |
| 207 |
=> int_and(x, C) |
| 208 |
|
| 209 |
lshift_and_urshift: int_lshift(int_and(uint_rshift(x, C1), C2), C1) |
| 210 |
check 0 <= C1 and C1 < LONG_BIT |
| 211 |
C = C2 << C1 |
| 212 |
=> int_and(x, C) |
| 213 |
|
| 214 |
|
| 215 |
lshift_lshift_c_c: int_lshift(int_lshift(x, C1), C2) |
| 216 |
check 0 <= C1 and C1 < LONG_BIT and 0 <= C2 and C2 < LONG_BIT |
| 217 |
C = C1 + C2 |
| 218 |
check C < LONG_BIT |
| 219 |
=> int_lshift(x, C) |
| 220 |
|
| 221 |
|
| 222 |
rshift_zero_x: int_rshift(0, x) |
| 223 |
=> 0 |
| 224 |
|
| 225 |
rshift_x_zero: int_rshift(x, 0) |
| 226 |
=> x |
| 227 |
|
| 228 |
rshift_known_result: int_rshift(a, b) |
| 229 |
bound = a.rshift_bound(b) |
| 230 |
check bound.is_constant() |
| 231 |
C = bound.get_constant_int() |
| 232 |
=> C |
| 233 |
|
| 234 |
rshift_lshift: int_rshift(int_lshift(x, y), y) |
| 235 |
check x.lshift_bound_cannot_overflow(y) |
| 236 |
=> x |
| 237 |
|
| 238 |
rshift_rshift_c_c: int_rshift(int_rshift(x, C1), C2) |
| 239 |
check 0 <= C1 and C1 < LONG_BIT and 0 <= C2 and C2 < LONG_BIT |
| 240 |
C = min(C1 + C2, LONG_BIT - 1) |
| 241 |
check 0 <= C and C < LONG_BIT |
| 242 |
=> int_rshift(x, C) |
| 243 |
|
| 244 |
#rshift_rshift_max: int_rshift(int_rshift(x, y), z) |
| 245 |
# check y.add_bound(z).known_ge_const(LONG_BIT) |
| 246 |
# C = LONG_BIT - 1 |
| 247 |
# => int_rshift(x, C) |
| 248 |
|
| 249 |
|
| 250 |
urshift_zero_x: uint_rshift(0, x) |
| 251 |
=> 0 |
| 252 |
|
| 253 |
urshift_x_zero: uint_rshift(x, 0) |
| 254 |
=> x |
| 255 |
|
| 256 |
urshift_known_result: uint_rshift(a, b) |
| 257 |
bound = a.urshift_bound(b) |
| 258 |
check bound.is_constant() |
| 259 |
C = bound.get_constant_int() |
| 260 |
=> C |
| 261 |
|
| 262 |
urshift_lshift_x_c_c: uint_rshift(int_lshift(x, C), C) |
| 263 |
mask = (-1 << C) >>u C |
| 264 |
=> int_and(x, mask) |
| 265 |
|
| 266 |
|
| 267 |
eq_different_knownbits: int_eq(x, y) |
| 268 |
SORRY_Z3 |
| 269 |
check x.known_ne(y) |
| 270 |
=> 0 |
| 271 |
|
| 272 |
eq_same: int_eq(x, x) |
| 273 |
=> 1 |
| 274 |
|
| 275 |
eq_one: int_eq(x, 1) |
| 276 |
check x.is_bool() |
| 277 |
=> x |
| 278 |
|
| 279 |
eq_zero: int_eq(x, 0) |
| 280 |
=> int_is_zero(x) |
| 281 |
|
| 282 |
eq_sub_eq: int_eq(int_sub(x, int_eq(x, a)), a) |
| 283 |
=> 0 |
| 284 |
|
| 285 |
#eq_add_const: int_eq(int_add(x, C1), C2) |
| 286 |
# C = C2 - C1 |
| 287 |
# => int_eq(x, C) |
| 288 |
|
| 289 |
ne_different_knownbits: int_ne(x, y) |
| 290 |
SORRY_Z3 |
| 291 |
check x.known_ne(y) |
| 292 |
=> 1 |
| 293 |
|
| 294 |
ne_same: int_ne(x, x) |
| 295 |
=> 0 |
| 296 |
|
| 297 |
ne_zero: int_ne(x, 0) |
| 298 |
=> int_is_true(x) |
| 299 |
|
| 300 |
#lt_self: int_lt(x, x) |
| 301 |
# => 0 |
| 302 |
|
| 303 |
|
| 304 |
is_true_bool: int_is_true(x) |
| 305 |
check x.is_bool() |
| 306 |
=> x |
| 307 |
|
| 308 |
is_true_true: int_is_true(x) |
| 309 |
check x.lower > 0 or x.upper < 0 or x.tvalue != 0 |
| 310 |
=> 1 |
| 311 |
|
| 312 |
is_true_and_minint: int_is_true(int_and(x, MININT)) |
| 313 |
=> int_lt(x, 0) |
| 314 |
|
| 315 |
|
| 316 |
is_zero_true: int_is_zero(x) |
| 317 |
check x.lower > 0 or x.upper < 0 or x.tvalue != 0 |
| 318 |
=> 0 |
| 319 |
|
| 320 |
#is_zero_is_zero: int_is_zero(int_is_zero(x)) |
| 321 |
# => int_is_true(x) |
| 322 |
# |
| 323 |
#uint_lt_zero: uint_lt(0, x) |
| 324 |
# => int_is_true(x) |
| 325 |
|
| 326 |
#is_zero_add: int_is_zero(int_add(x, C)) |
| 327 |
# check x.lower > 0-C or x.upper < 0-C |
| 328 |
# => 0 |
| 329 |
|
| 330 |
#is_zero_negate_eq: int_is_zero(int_eq(x, y)) |
| 331 |
# => int_ne(x, y) |
| 332 |
|
| 333 |
#is_zero_negate_ne: int_is_zero(int_ne(x, y)) |
| 334 |
# => int_eq(x, y) |
| 335 |
|
| 336 |
#is_zero_is_true: int_is_zero(int_is_true(x)) |
| 337 |
# => int_is_zero(x) |
| 338 |
|
| 339 |
#is_zero_or: int_is_zero(int_or(x, y)) |
| 340 |
# # this is because x | y = x ^ y + x & y |
| 341 |
# # and x ^ y == 0 <=> x == y |
| 342 |
# check x.and_bound(y).known_eq_const(0) |
| 343 |
# => int_eq(x, y) |
| 344 |
|
| 345 |
force_ge_zero_pos: int_force_ge_zero(x) |
| 346 |
check x.known_nonnegative() |
| 347 |
=> x |
| 348 |
|
| 349 |
force_ge_zero_neg: int_force_ge_zero(x) |
| 350 |
check x.known_lt_const(0) |
| 351 |
=> 0 |
| 352 |
|
| 353 |
invert_invert: int_invert(int_invert(x)) |
| 354 |
=> x |
| 355 |
|
| 356 |
neg_neg: int_neg(int_neg(x)) |
| 357 |
=> x |
| 358 |
|
| 359 |
|
| 360 |
#le_self: int_le(x, x) |
| 361 |
# => 1 |
| 362 |
# |
| 363 |
#le_known_true: int_le(x, y) |
| 364 |
# check x.known_le(y) |
| 365 |
# => 1 |
| 366 |
# |
| 367 |
#le_known_false: int_le(x, y) |
| 368 |
# check x.known_gt(y) |
| 369 |
# => 0 |
| 370 |
# |
| 371 |
#le_maxint: int_le(x, MAXINT) |
| 372 |
# => 1 |
| 373 |
# |
| 374 |
#le_minint: int_le(x, MININT) |
| 375 |
# => int_eq(x, MININT) |
| 376 |
# |
| 377 |
#ge_from_sub: int_ge(int_sub(x, y), x) |
| 378 |
# check y.known_gt_const(0) |
| 379 |
# check x.sub_bound_cannot_overflow(y) |
| 380 |
# => 0 |
| 381 |
# |
| 382 |
|
| 383 |
#int_or_shift_recombine: int_or(int_lshift(uint_rshift(x, C1), C2), int_and(uint_rshift(x, C3), C4)) |
| 384 |
# check C1 == C3 + C2 |
| 385 |
# check C4 == (1 << C2) - 1 |
| 386 |
# => uint_rshift(x, C3) |