@@ -53,7 +53,8 @@ internal fun NumericInstructionFuser(
5353 input = input,
5454 output = output,
5555 unop = ::UnopFuser ,
56- binop = ::NumericBinopFuser ,
56+ commutativeBinop = ::CommutativeBinopFuser ,
57+ nonCommutativeBinop = ::NonCommutativeBinopFuser ,
5758)
5859
5960internal inline fun NumericInstructionFuser (
@@ -63,43 +64,44 @@ internal inline fun NumericInstructionFuser(
6364 input : List <Instruction >,
6465 output : MutableList <Instruction >,
6566 unop : UnopFuser ,
66- binop : BinopFuser ,
67+ commutativeBinop : BinopFuser ,
68+ nonCommutativeBinop : BinopFuser ,
6769): Int = when (instruction) {
68- is NumericInstruction .I32Add -> binop (index, instruction, input, output, ::I32Add )
69- is NumericInstruction .I32Sub -> binop (index, instruction, input, output, ::I32Sub )
70- is NumericInstruction .I32Mul -> binop (index, instruction, input, output, ::I32Mul )
71- is NumericInstruction .I32DivS -> binop (index, instruction, input, output, ::I32DivS )
72- is NumericInstruction .I32DivU -> binop (index, instruction, input, output, ::I32DivU )
73- is NumericInstruction .I32And -> binop (index, instruction, input, output, ::I32And )
74- is NumericInstruction .I32Or -> binop (index, instruction, input, output, ::I32Or )
75- is NumericInstruction .I32Xor -> binop (index, instruction, input, output, ::I32Xor )
76- is NumericInstruction .I32Shl -> binop (index, instruction, input, output, ::I32Shl )
77- is NumericInstruction .I32ShrS -> binop (index, instruction, input, output, ::I32ShrS )
78- is NumericInstruction .I32ShrU -> binop (index, instruction, input, output, ::I32ShrU )
79- is NumericInstruction .I32LtS -> binop (index, instruction, input, output, ::I32LtS )
80- is NumericInstruction .I32LtU -> binop (index, instruction, input, output, ::I32LtU )
81- is NumericInstruction .I32GtS -> binop (index, instruction, input, output, ::I32GtS )
82- is NumericInstruction .I32GtU -> binop (index, instruction, input, output, ::I32GtU )
83- is NumericInstruction .I32LeS -> binop (index, instruction, input, output, ::I32LeS )
84- is NumericInstruction .I32LeU -> binop (index, instruction, input, output, ::I32LeU )
85- is NumericInstruction .I32GeS -> binop (index, instruction, input, output, ::I32GeS )
86- is NumericInstruction .I32GeU -> binop (index, instruction, input, output, ::I32GeU )
70+ is NumericInstruction .I32Add -> nonCommutativeBinop (index, instruction, input, output, ::I32Add )
71+ is NumericInstruction .I32Sub -> nonCommutativeBinop (index, instruction, input, output, ::I32Sub )
72+ is NumericInstruction .I32Mul -> commutativeBinop (index, instruction, input, output, ::I32Mul )
73+ is NumericInstruction .I32DivS -> nonCommutativeBinop (index, instruction, input, output, ::I32DivS )
74+ is NumericInstruction .I32DivU -> nonCommutativeBinop (index, instruction, input, output, ::I32DivU )
75+ is NumericInstruction .I32And -> commutativeBinop (index, instruction, input, output, ::I32And )
76+ is NumericInstruction .I32Or -> commutativeBinop (index, instruction, input, output, ::I32Or )
77+ is NumericInstruction .I32Xor -> commutativeBinop (index, instruction, input, output, ::I32Xor )
78+ is NumericInstruction .I32Shl -> nonCommutativeBinop (index, instruction, input, output, ::I32Shl )
79+ is NumericInstruction .I32ShrS -> nonCommutativeBinop (index, instruction, input, output, ::I32ShrS )
80+ is NumericInstruction .I32ShrU -> nonCommutativeBinop (index, instruction, input, output, ::I32ShrU )
81+ is NumericInstruction .I32LtS -> nonCommutativeBinop (index, instruction, input, output, ::I32LtS )
82+ is NumericInstruction .I32LtU -> nonCommutativeBinop (index, instruction, input, output, ::I32LtU )
83+ is NumericInstruction .I32GtS -> nonCommutativeBinop (index, instruction, input, output, ::I32GtS )
84+ is NumericInstruction .I32GtU -> nonCommutativeBinop (index, instruction, input, output, ::I32GtU )
85+ is NumericInstruction .I32LeS -> nonCommutativeBinop (index, instruction, input, output, ::I32LeS )
86+ is NumericInstruction .I32LeU -> nonCommutativeBinop (index, instruction, input, output, ::I32LeU )
87+ is NumericInstruction .I32GeS -> nonCommutativeBinop (index, instruction, input, output, ::I32GeS )
88+ is NumericInstruction .I32GeU -> nonCommutativeBinop (index, instruction, input, output, ::I32GeU )
8789 is NumericInstruction .I32Eqz -> unop(index, instruction, input, output, ::I32Eqz )
8890 is NumericInstruction .I64Eqz -> unop(index, instruction, input, output, ::I64Eqz )
89- is NumericInstruction .I64Add -> binop (index, instruction, input, output, ::I64Add )
90- is NumericInstruction .I64Sub -> binop (index, instruction, input, output, ::I64Sub )
91- is NumericInstruction .I64Mul -> binop (index, instruction, input, output, ::I64Mul )
92- is NumericInstruction .I64DivS -> binop (index, instruction, input, output, ::I64DivS )
93- is NumericInstruction .I64DivU -> binop (index, instruction, input, output, ::I64DivU )
91+ is NumericInstruction .I64Add -> nonCommutativeBinop (index, instruction, input, output, ::I64Add )
92+ is NumericInstruction .I64Sub -> nonCommutativeBinop (index, instruction, input, output, ::I64Sub )
93+ is NumericInstruction .I64Mul -> commutativeBinop (index, instruction, input, output, ::I64Mul )
94+ is NumericInstruction .I64DivS -> nonCommutativeBinop (index, instruction, input, output, ::I64DivS )
95+ is NumericInstruction .I64DivU -> nonCommutativeBinop (index, instruction, input, output, ::I64DivU )
9496 is NumericInstruction .F32Abs -> unop(index, instruction, input, output, ::F32Abs )
95- is NumericInstruction .F32Add -> binop (index, instruction, input, output, ::F32Add )
96- is NumericInstruction .F32Sub -> binop (index, instruction, input, output, ::F32Sub )
97- is NumericInstruction .F32Mul -> binop (index, instruction, input, output, ::F32Mul )
98- is NumericInstruction .F32Div -> binop (index, instruction, input, output, ::F32Div )
99- is NumericInstruction .F64Add -> binop (index, instruction, input, output, ::F64Add )
100- is NumericInstruction .F64Sub -> binop (index, instruction, input, output, ::F64Sub )
101- is NumericInstruction .F64Mul -> binop (index, instruction, input, output, ::F64Mul )
102- is NumericInstruction .F64Div -> binop (index, instruction, input, output, ::F64Div )
97+ is NumericInstruction .F32Add -> commutativeBinop (index, instruction, input, output, ::F32Add )
98+ is NumericInstruction .F32Sub -> nonCommutativeBinop (index, instruction, input, output, ::F32Sub )
99+ is NumericInstruction .F32Mul -> commutativeBinop (index, instruction, input, output, ::F32Mul )
100+ is NumericInstruction .F32Div -> nonCommutativeBinop (index, instruction, input, output, ::F32Div )
101+ is NumericInstruction .F64Add -> nonCommutativeBinop (index, instruction, input, output, ::F64Add )
102+ is NumericInstruction .F64Sub -> nonCommutativeBinop (index, instruction, input, output, ::F64Sub )
103+ is NumericInstruction .F64Mul -> commutativeBinop (index, instruction, input, output, ::F64Mul )
104+ is NumericInstruction .F64Div -> nonCommutativeBinop (index, instruction, input, output, ::F64Div )
103105 else -> {
104106 output.add(instruction)
105107 index
0 commit comments