From 3b3081479163475f25b908008250d83c31716c34 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 5 Dec 2018 21:36:10 -0600 Subject: nir/algebraic: Optimize 1-bit Booleans Reviewed-by: Eric Anholt Reviewed-by: Bas Nieuwenhuizen Tested-by: Bas Nieuwenhuizen --- src/compiler/nir/nir_algebraic.py | 40 ++++++--------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) (limited to 'src/compiler/nir/nir_algebraic.py') diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py index 9a28421b799..a667c4170f1 100644 --- a/src/compiler/nir/nir_algebraic.py +++ b/src/compiler/nir/nir_algebraic.py @@ -210,8 +210,8 @@ class Constant(Value): self._bit_size = None if isinstance(self.value, bool): - assert self._bit_size is None or self._bit_size == 32 - self._bit_size = 32 + assert self._bit_size is None or self._bit_size == 1 + self._bit_size = 1 def hex(self): if isinstance(self.value, (bool)): @@ -258,8 +258,10 @@ class Variable(Value): self._bit_size = int(m.group('bits')) if m.group('bits') else None if self.required_type == 'bool': - assert self._bit_size is None or self._bit_size == 32 - self._bit_size = 32 + if self._bit_size is not None: + assert self._bit_size in type_sizes(self.required_type) + else: + self._bit_size = 1 if self.required_type is not None: assert self.required_type in ('float', 'bool', 'int', 'uint') @@ -277,34 +279,6 @@ class Variable(Value): _opcode_re = re.compile(r"(?P~)?(?P\w+)(?:@(?P\d+))?" r"(?P\([^\)]+\))?") -opcode_remap = { - 'flt' : 'flt32', - 'fge' : 'fge32', - 'feq' : 'feq32', - 'fne' : 'fne32', - 'ilt' : 'ilt32', - 'ige' : 'ige32', - 'ieq' : 'ieq32', - 'ine' : 'ine32', - 'ult' : 'ult32', - 'uge' : 'uge32', - - 'ball_iequal2' : 'b32all_iequal2', - 'ball_iequal3' : 'b32all_iequal3', - 'ball_iequal4' : 'b32all_iequal4', - 'bany_inequal2' : 'b32any_inequal2', - 'bany_inequal3' : 'b32any_inequal3', - 'bany_inequal4' : 'b32any_inequal4', - 'ball_fequal2' : 'b32all_fequal2', - 'ball_fequal3' : 'b32all_fequal3', - 'ball_fequal4' : 'b32all_fequal4', - 'bany_fnequal2' : 'b32any_fnequal2', - 'bany_fnequal3' : 'b32any_fnequal3', - 'bany_fnequal4' : 'b32any_fnequal4', - - 'bcsel' : 'b32csel', -} - class Expression(Value): def __init__(self, expr, name_base, varset): Value.__init__(self, expr, name_base, "expression") @@ -314,8 +288,6 @@ class Expression(Value): assert m and m.group('opcode') is not None self.opcode = m.group('opcode') - if self.opcode in opcode_remap: - self.opcode = opcode_remap[self.opcode] self._bit_size = int(m.group('bits')) if m.group('bits') else None self.inexact = m.group('inexact') is not None self.cond = m.group('cond') -- cgit v1.2.3