cranelift: simplify fneg(fneg(x)) to x (#6034)
This commit is contained in:
@@ -527,6 +527,9 @@
|
|||||||
;; with the `bitselect` instruction, but the pattern is a bit more complicated
|
;; with the `bitselect` instruction, but the pattern is a bit more complicated
|
||||||
;; due to most bitselects-over-floats having bitcasts.
|
;; due to most bitselects-over-floats having bitcasts.
|
||||||
|
|
||||||
|
;; fneg(fneg(x)) == x.
|
||||||
|
(rule (simplify (fneg ty (fneg ty x))) (subsume x))
|
||||||
|
|
||||||
;; If both of the multiplied arguments to an `fma` are negated then remove
|
;; If both of the multiplied arguments to an `fma` are negated then remove
|
||||||
;; both of them since they cancel out.
|
;; both of them since they cancel out.
|
||||||
(rule (simplify (fma ty (fneg ty x) (fneg ty y) z))
|
(rule (simplify (fma ty (fneg ty x) (fneg ty y) z))
|
||||||
|
|||||||
@@ -492,6 +492,15 @@ block0(v1: i16):
|
|||||||
; check: v4 = sextend.i64 v1
|
; check: v4 = sextend.i64 v1
|
||||||
; check: return v4
|
; check: return v4
|
||||||
|
|
||||||
|
function %double_fneg(f32) -> f32 {
|
||||||
|
block0(v1: f32):
|
||||||
|
v2 = fneg v1
|
||||||
|
v3 = fneg v2
|
||||||
|
return v3
|
||||||
|
}
|
||||||
|
|
||||||
|
; check: return v1
|
||||||
|
|
||||||
function %fma_double_fneg(f32, f32, f32) -> f32 {
|
function %fma_double_fneg(f32, f32, f32) -> f32 {
|
||||||
block0(v1: f32, v2: f32, v3: f32):
|
block0(v1: f32, v2: f32, v3: f32):
|
||||||
v4 = fneg v1
|
v4 = fneg v1
|
||||||
|
|||||||
Reference in New Issue
Block a user