add reminder by a power of two peephole rule

This commit is contained in:
MaxGraey
2020-07-03 09:44:59 +03:00
parent d87ada209c
commit d839d83f7e
2 changed files with 5 additions and 0 deletions

View File

@@ -191,3 +191,8 @@
(=> (when (udiv_imm $C $x)
(is-power-of-two $C))
(ushr_imm $(log2 $C) $x))
;; Reminder by a power of two -> bitwise and with decreased by one constant.
(=> (when (urem_imm $C $x)
(is-power-of-two $C))
(band_imm $(iadd -1 $C) $x))