Skip to content
Snippets Groups Projects
Commit 6e3a147c authored by Michael Kuron's avatar Michael Kuron 🎓
Browse files

don't convert plain negation into fused-multiple add

parent 8bebd100
1 merge request!414Draft: Fused-multiply-add vectorization
Pipeline #68929 failed with stages
in 2 minutes and 55 seconds
...@@ -220,13 +220,14 @@ def insert_fma(term, operators): ...@@ -220,13 +220,14 @@ def insert_fma(term, operators):
# Find Mul with three factors, one of them -1, which can be fused # Find Mul with three factors, one of them -1, which can be fused
elif expr.func == sp.Mul and -1 in expr.args: elif expr.func == sp.Mul and -1 in expr.args:
expr = flatten(expr) expr = flatten(expr)
factors = list(expr.args) if len(expr.args) > 2:
factors.remove(-1) factors = list(expr.args)
factors = [visit(f) for f in factors] factors.remove(-1)
if '-*+' in operators: factors = [visit(f) for f in factors]
return fnmadd(factors[0], sp.Mul(*factors[1:]), 0) if '-*+' in operators:
elif '-*-' in operators: return fnmadd(factors[0], sp.Mul(*factors[1:]), 0)
return fnmsub(factors[0], sp.Mul(*factors[1:]), 0) elif '-*-' in operators:
return fnmsub(factors[0], sp.Mul(*factors[1:]), 0)
new_args = [visit(a) for a in expr.args] new_args = [visit(a) for a in expr.args]
return expr.func(*new_args) if new_args else expr return expr.func(*new_args) if new_args else expr
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment