nir/search: Don't compare 8-bit or 1-bit constants with floats
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 20 Mar 2019 20:42:46 +0000 (13:42 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 14 May 2019 18:38:22 +0000 (11:38 -0700)
commite2ad047779b02b48d35de8adaf92feed0f58aa3e
treec7fb8cd8c4f79cc2c3157c3d74e978167a0d1836
parent5116646a7636ebc99714d1a0cc41cd402a915220
nir/search: Don't compare 8-bit or 1-bit constants with floats

Without this, adding an algebraic rule like

   (('bcsel', ('flt', a, 0.0), 0.0, ...), ...),

will cause assertion failures inside nir_src_comp_as_float in
GTF-GL46.gtf21.GL.lessThan.lessThan_vec3_frag (and related tests) from
the OpenGL CTS and shaders/closed/steam/witcher-2/511.shader_test from
shader-db.

All of these cases have some code that ends up like

   ('bcsel', ('flt', a, 0.0), 'b@1', ...)

When the 'b@1' is tested, nir_src_comp_as_float fails because there's
no such thing as a 1-bit float.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
src/compiler/nir/nir_search.c