nir: Don't reassociate add/mul chains containing only constants
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 15 Feb 2019 22:52:20 +0000 (14:52 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Sun, 17 Feb 2019 07:36:14 +0000 (23:36 -0800)
commit535251487ba56c4fd98465c4682881c2b9734242
treed0a6a68d4a0a43b21b3e3daffbe21c31ecdb393a
parente9882b879b9c2da74b3b6cc6ed7fa2fd4e9c8e92
nir: Don't reassociate add/mul chains containing only constants

The idea here is to reassociate a * (b * c) into (a * c) * b, when
b is a non-constant value, but a and c are constants, allowing them
to be combined.

But nothing was enforcing that 'b' must be non-constant, which meant
that running opt_algebraic in a loop would never terminate if the IR
contained non-folded constant expressions like 256 * 0.5 * 2.  Normally,
we call constant folding in such a loop too, but IMO it's better for
nir_opt_algebraic to be robust and not rely on that.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109581
Fixes: 32e266a9a58 i965: Compile fp64 funcs only if we do not have 64-bit hardware support
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/compiler/nir/nir_opt_algebraic.py