From 8c4fdf49d432486b526ffbeb6fb375094ff424fd Mon Sep 17 00:00:00 2001 From: Sasha Lopoukhine Date: Mon, 18 Nov 2024 23:21:21 +0000 Subject: [PATCH] copy name hint when rewriting --- .../apply-eqsat-pdl/apply_eqsat_pdl_swap_inputs.mlir | 6 +++--- xdsl/interpreters/eqsat_pdl.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/filecheck/transforms/apply-eqsat-pdl/apply_eqsat_pdl_swap_inputs.mlir b/tests/filecheck/transforms/apply-eqsat-pdl/apply_eqsat_pdl_swap_inputs.mlir index 12b4365af1..b09211c3a6 100644 --- a/tests/filecheck/transforms/apply-eqsat-pdl/apply_eqsat_pdl_swap_inputs.mlir +++ b/tests/filecheck/transforms/apply-eqsat-pdl/apply_eqsat_pdl_swap_inputs.mlir @@ -5,9 +5,9 @@ // CHECK-NEXT: %c4_eq = eqsat.eclass %c4 : i32 // CHECK-NEXT: %c2 = arith.constant 2 : i32 // CHECK-NEXT: %c2_eq = eqsat.eclass %c2 : i32 -// CHECK-NEXT: %0 = arith.addi %c2_eq, %c4_eq : i32 -// CHECK-NEXT: %sum = arith.addi %c4_eq, %c2_eq : i32 -// CHECK-NEXT: %sum_eq = eqsat.eclass %sum, %0 : i32 +// CHECK-NEXT: %sum = arith.addi %c2_eq, %c4_eq : i32 +// CHECK-NEXT: %sum_1 = arith.addi %c4_eq, %c2_eq : i32 +// CHECK-NEXT: %sum_eq = eqsat.eclass %sum_1, %sum : i32 // CHECK-NEXT: func.return %sum_eq : i32 // CHECK-NEXT: } diff --git a/xdsl/interpreters/eqsat_pdl.py b/xdsl/interpreters/eqsat_pdl.py index 5fc1dbbbb3..564b750be7 100644 --- a/xdsl/interpreters/eqsat_pdl.py +++ b/xdsl/interpreters/eqsat_pdl.py @@ -226,6 +226,7 @@ def run_replace( # Add new op to eclass results = new_op.results assert len(results) == 1 + results[0].name_hint = old.results[0].name_hint eclass_op = self.value_to_eclass[old.results[0]] eclass_op.operands = eclass_op.arguments + results elif op.repl_values: