Skip to content

Commit

Permalink
Add missing unsigned multiply case to simplify_trivial_arithmetic.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rihi committed Sep 20, 2023
1 parent 9207491 commit 97ed807
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class SimplifyTrivialArithmetic(SimplificationRule):
- `e + 0 -> e`
- `e - 0 -> e`
- `e * 0 -> 0`
- `e u* 0 -> 0`
- `e * 1 -> e`
- `e u* 1 -> e`
- `e * -1 -> -e`
Expand All @@ -26,7 +28,7 @@ def apply(self, operation: Operation) -> list[tuple[Expression, Expression]]:
right=Constant(value=1),
):
return [(operation, operation.left)]
case BinaryOperation(operation=OperationType.multiply, right=Constant(value=0)):
case BinaryOperation(operation=OperationType.multiply | OperationType.multiply_us, right=Constant(value=0)):
return [(operation, Constant(0, operation.type))]
case BinaryOperation(
operation=OperationType.multiply | OperationType.multiply_us | OperationType.divide,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
[
(BinaryOperation(OperationType.plus, [var, con_0]), [var]),
(BinaryOperation(OperationType.minus, [var, con_0]), [var]),
(BinaryOperation(OperationType.multiply, [var, con_0]), [con_0]),
(BinaryOperation(OperationType.multiply_us, [var, con_0]), [con_0]),
(BinaryOperation(OperationType.multiply, [var, con_1]), [var]),
(BinaryOperation(OperationType.multiply_us, [var, con_1]), [var]),
(BinaryOperation(OperationType.multiply, [var, con_neg1]), [UnaryOperation(OperationType.negate, [var])]),
Expand Down

0 comments on commit 97ed807

Please sign in to comment.