Merge pull request #1975 from MaxGraey/more-peephole-opts

peepmatic: add reminder by a power of two rule
This commit is contained in:
Nick Fitzgerald
2020-07-06 16:32:16 -07:00
committed by GitHub
4 changed files with 13 additions and 1 deletions

View File

@@ -191,3 +191,9 @@
(=> (when (udiv_imm $C $x)
(is-power-of-two $C))
(ushr_imm $(log2 $C) $x))
;; Remainder by a power of two -> bitwise and with decreased by one constant.
(=> (when (urem_imm $C $x)
(is-power-of-two $C)
(fits-in-native-word $C))
(band_imm $(isub $C 1) $x))