Add egraph optimization for fneg's cancelling out (#5910)

This implements comments from #5895 to cancel out `fneg` operations in
`fma` instructions. Additional support for `fmul` is added as well.
This commit is contained in:
Alex Crichton
2023-03-02 12:28:32 -06:00
committed by GitHub
parent 87672f7059
commit 3ff3994a12
2 changed files with 32 additions and 0 deletions

View File

@@ -527,3 +527,13 @@
(rule (simplify
(vselect ty (fcmp _ (FloatCC.GreaterThan) x y) x y))
(fmax_pseudo ty x y))
;; If both of the multiplied arguments to an `fma` are negated then remove
;; both of them since they cancel out.
(rule (simplify (fma ty (fneg ty x) (fneg ty y) z))
(fma ty x y z))
;; If both of the multiplied arguments to an `fmul` are negated then remove
;; both of them since they cancel out.
(rule (simplify (fmul ty (fneg ty x) (fneg ty y)))
(fmul ty x y))