summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_algebraic.py
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-12-05 21:36:10 -0600
committerJason Ekstrand <[email protected]>2018-12-16 21:03:02 +0000
commit3b3081479163475f25b908008250d83c31716c34 (patch)
treee40bcc2cf423b647d0c027700f9fbf40722d1c18 /src/compiler/nir/nir_algebraic.py
parent44227453ec03f5462f1cff5760909a9dba95c61a (diff)
nir/algebraic: Optimize 1-bit Booleans
Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]> Tested-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_algebraic.py')
-rw-r--r--src/compiler/nir/nir_algebraic.py40
1 files changed, 6 insertions, 34 deletions
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<inexact>~)?(?P<opcode>\w+)(?:@(?P<bits>\d+))?"
r"(?P<cond>\([^\)]+\))?")
-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')