nir: Add a flag for lowering fsqrt(x) to frcp(frsqrt(x)).
[mesa.git] / src / glsl / nir / nir_opt_algebraic.py
index b8b28f1d6d18145ad926a3dedcdcbd8655379140..f93757e032505f0c42b59d38628fe5b1df0b45d3 100644 (file)
@@ -128,7 +128,8 @@ optimizations = [
    (('fdiv', 1.0, a), ('frcp', a)),
    (('frcp', ('frcp', a)), a),
    (('frcp', ('fsqrt', a)), ('frsq', a)),
-   (('frcp', ('frsq', a)), ('fsqrt', a)),
+   (('fsqrt', a), ('frcp', ('frsq', a)), 'options->lower_fsqrt'),
+   (('frcp', ('frsq', a)), ('fsqrt', a), '!options->lower_fsqrt'),
    # Boolean simplifications
    (('ine', 'a@bool', 0), 'a'),
    (('ieq', 'a@bool', 0), ('inot', 'a')),