-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
interpreter: (pdl) fix multiple inserted operations in rewrite pattern interpreter #3569
Comments
I would recommend doing a different approach to the one here: https://github.com/xdslproject/xdsl/pull/3402/files#diff-571b0c5cfc943738c6c960434941019e3e0fdc733da7c96dc242bd727e182ff6R402-R415 Instead, accumulating operations created in the pass to a work list, and adding them in the end, instead of getting them from a use-def chain at the end. |
@cowardsa to provide example |
builtin.module {
pdl.pattern : benefit(1) {
%x = pdl.operand
%y = pdl.operand
%z = pdl.operand
%type = pdl.type
%accumop = pdl.operation "arith.addi" (%x, %y : !pdl.value, !pdl.value) -> (%type : !pdl.type)
%accum = pdl.result 0 of %accumop
%resultop = pdl.operation "arith.addi" (%accum, %z : !pdl.value, !pdl.value) -> (%type : !pdl.type)
%result = pdl.result 0 of %resultop
pdl.rewrite %resultop {
%newaccumop = pdl.operation "arith.addi" (%y, %z : !pdl.value, !pdl.value) -> (%type : !pdl.type)
%newaccum = pdl.result 0 of %newaccumop
%newresultop = pdl.operation "arith.addi" (%x, %newaccum : !pdl.value, !pdl.value) -> (%type : !pdl.type)
%newresult = pdl.result 0 of %newresultop
pdl.replace %accumop with %newaccumop
pdl.replace %resultop with %newresultop
}
}
func.func @impl() -> i32 {
%a = arith.constant 3 : i32
%a_1 = eqsat.eclass %a : i32
%b = arith.constant 5 : i32
%b_1 = eqsat.eclass %b : i32
%c = arith.constant 7 : i32
%c_1 = eqsat.eclass %c : i32
%d = arith.addi %a_1, %b_1 : i32
%d_1 = eqsat.eclass %d : i32
%e = arith.addi %d_1, %c_1 : i32
%e_1 = eqsat.eclass %e : i32
func.return %e_1 : i32
}
} Looking into this issue, is this a test case where a rewrite should occur? |
I'm not sure I understand your question, but my understanding is that the expected PDL pattern is only the last line, not the previous one, as the newresult will have the same value as result, and newaccumop will not have the same value as accumop. |
(a + b) + c -> a + (b + c)
The text was updated successfully, but these errors were encountered: