|
347 | 347 | ;; (x - y) - x => -y |
348 | 348 | (rule (simplify (isub ty (isub ty x y) x))(ineg ty y)) |
349 | 349 |
|
| 350 | +;; (x * C) (==/!=) D --> x (==/!=) (D / C) when C is odd and divides D |
| 351 | +(rule |
| 352 | + (simplify (ne ty (iconst_u ty1 x) (imul ty1 y (iconst_u ty1 z)))) |
| 353 | + (if-let 0 (u64_rem x z)) |
| 354 | + (if-let 1 (u64_rem z 2)) |
| 355 | + (ne ty y (iconst ty1 (imm64 (u64_div x z))))) |
| 356 | +(rule |
| 357 | + (simplify (ne ty (iconst_u ty1 x) (imul ty1 (iconst_u ty1 y) z))) |
| 358 | + (if-let 0 (u64_rem x y)) |
| 359 | + (if-let 1 (u64_rem y 2)) |
| 360 | + (ne ty z (iconst ty1 (imm64 (u64_div x y))))) |
| 361 | +(rule |
| 362 | + (simplify (ne ty (imul ty1 x (iconst_u ty1 y)) (iconst_u ty1 z))) |
| 363 | + (if-let 0 (u64_rem z y)) |
| 364 | + (if-let 1 (u64_rem y 2)) |
| 365 | + (ne ty x (iconst ty1 (imm64 (u64_div z y))))) |
| 366 | +(rule |
| 367 | + (simplify (ne ty (imul ty1 (iconst_u ty1 x) y) (iconst_u ty1 z))) |
| 368 | + (if-let 0 (u64_rem z x)) |
| 369 | + (if-let 1 (u64_rem x 2)) |
| 370 | + (ne ty y (iconst ty1 (imm64 (u64_div z x))))) |
| 371 | + |
| 372 | + |
| 373 | +(rule |
| 374 | + (simplify (eq ty (iconst_u ty1 x) (imul ty1 y (iconst_u ty1 z)))) |
| 375 | + (if-let 0 (u64_rem x z)) |
| 376 | + (if-let 1 (u64_rem z 2)) |
| 377 | + (eq ty y (iconst ty1 (imm64 (u64_div x z))))) |
| 378 | +(rule |
| 379 | + (simplify (eq ty (iconst_u ty1 x) (imul ty1 (iconst_u ty1 y) z))) |
| 380 | + (if-let 0 (u64_rem x y)) |
| 381 | + (if-let 1 (u64_rem y 2)) |
| 382 | + (eq ty z (iconst ty1 (imm64 (u64_div x y))))) |
| 383 | +(rule |
| 384 | + (simplify (eq ty (imul ty1 x (iconst_u ty1 y)) (iconst_u ty1 z))) |
| 385 | + (if-let 0 (u64_rem z y)) |
| 386 | + (if-let 1 (u64_rem y 2)) |
| 387 | + (eq ty x (iconst ty1 (imm64 (u64_div z y))))) |
| 388 | +(rule |
| 389 | + (simplify (eq ty (imul ty1 (iconst_u ty1 x) y) (iconst_u ty1 z))) |
| 390 | + (if-let 0 (u64_rem z x)) |
| 391 | + (if-let 1 (u64_rem x 2)) |
| 392 | + (eq ty y (iconst ty1 (imm64 (u64_div z x))))) |
| 393 | + |
| 394 | + |
0 commit comments