Skip to content

Commit

Permalink
Relaxe checks in collapse_nested_constants.py to allow more simplific…
Browse files Browse the repository at this point in the history
…ations
  • Loading branch information
rihi committed Jul 3, 2024
1 parent 6613dd2 commit 24faaef
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ def _collect_constants(operation: Operation) -> Iterator[Constant]:
current_operation = context_stack.pop()

for i, operand in enumerate(current_operation.operands):
if operand.type != operand_type: # This check could potentially be relaxed to only check for equal size
if operand.type.size != operand_type.size:
continue

if isinstance(operand, Operation):
if operand.operation == operation_type:
context_stack.append(operand)
continue
elif isinstance(operand, Constant) and _identity_constant(operation_type, operand_type).value != operand.value:
elif isinstance(operand, Constant) and isinstance(operand.value, int) and _identity_constant(operation_type, operand_type).value != operand.value:
yield operand


Expand Down

0 comments on commit 24faaef

Please sign in to comment.