This PR improves the spirv::CompositeExtractOp::fold function by adding a backtracking mechanism.
The updated function can now traverse a chain of CompositeInsertOps to find a match.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp | ||
---|---|---|
146–147 | nit: since insertOp is not used outside of the loop, you should be able to reduce the scope like so: while (auto insertOp = compositeOp.getDefiningOp<spirv::CompositeInsertOp>()) { if (getIndices() == insertOp.getIndices()) return insertOp.getObject(); compositeOp = insertOp.getComposite(); } | |
153–154 | Would we look through insertions and then look through composite constructs? I think we should be able to resume from compositeOp updated in the loop above. | |
153–154 | *Should | |
mlir/test/Dialect/SPIRV/Transforms/canonicalize.mlir | ||
199 | nit: I think CHECK-NEXT: return .... would work here and we would not have to use CHECK-NOT. |
mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp | ||
---|---|---|
153–154 | not exactly sure what you mean here |
mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp | ||
---|---|---|
151 | We shouldn't need this since insertOp gets reassigned in the loop condition | |
153–154 | I mean supporting sequences like this: %a = spirv.CompositeConstruct %0, %1, %2 %b = spirv.CompositeInsert %3, %a[1] %c = spirv.CompositeInsert %4, %b[2] %val = spirv.CompositeExtract %c[0] return %val ==> return %0 |
@kuhar not sure why it shows patch application failed. Should I create a revision again?
Awesome, thanks for the fixes!
Can you share some more context? What did you do and where did you see this message? In general, phabricator doesn't require creating new revisions when things go out of sync -- you should be able to rebase and upload an updated diff based on that.
in the diff details it shows this
"Diff Detail
Build Status
Buildable 234970
Build 363444: pre-merge checks patch application failed"
Do I have to rebase on latest master? I used the gui for creating the PR and revisions, it worked fine until the last revision
Also, can you help merge the patch for me since I dont think I have permission nor do I know how to merge it in upstream llvm repo
I think it could be that the patch is too far behind for the CI to pick up, and then the fix would be to rebase and upload a new diff.
Sure, I can commit it for you. What name and email would you like to use?
nit: since insertOp is not used outside of the loop, you should be able to reduce the scope like so: