Skip to content
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

[mlir][spirv] Add missing folding for scalar/vector SPIR-V ops #70704

Closed
inbelic opened this issue Oct 30, 2023 · 3 comments
Closed

[mlir][spirv] Add missing folding for scalar/vector SPIR-V ops #70704

inbelic opened this issue Oct 30, 2023 · 3 comments
Assignees

Comments

@inbelic
Copy link
Contributor

inbelic commented Oct 30, 2023

It has been noted that we are missing the fold definitions for various basic scalar/vector SPIR-V ops. As a result, many of these operations are not folded away in the IR and it is required to use other tools to do so, eg: spirv-opt. We are motivated to do so as it would allow for the IR to be more readable, particularly when we have transformed/lowered from another dialect into SPIR-V and are generating new operations that have the potential to be folded away.

@inbelic
Copy link
Contributor Author

inbelic commented Oct 30, 2023

I have begun work on this and will add a draft PR in the next couple days.

@kuhar I will ping you here to follow along and to request that you assign me to the issue as well, thanks.

@kuhar kuhar changed the title [SPIRV] Add missing folding for scalar/vector SPIR-V ops [mlir][spirv] Add missing folding for scalar/vector SPIR-V ops Oct 30, 2023
@llvmbot
Copy link
Member

llvmbot commented Oct 30, 2023

@llvm/issue-subscribers-mlir-spirv

Author: Finn Plummer (inbelic)

It has been noted that we are missing the fold definitions for various basic scalar/vector SPIR-V ops. As a result, many of these operations are not folded away in the IR and it is required to use other tools to do so, eg: spirv-opt. We are motivated to do so as it would allow for the IR to be more readable, particularly when we have transformed/lowered from another dialect into SPIR-V and are generating new operations that have the potential to be folded away.

inbelic added a commit to inbelic/llvm-project that referenced this issue Nov 21, 2023
We have missing basic constant folds for SPIR-V arithmetic operations which
negatively impacts readability of lowered or otherwise generated code. This
commit works to implementing them to improve the mentioned hinderences.
Also corrects some folds that were found to be incorrect during testing.

Resolves llvm#70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Nov 21, 2023
We have missing basic constant folds for SPIR-V bit operations which
negatively impacts readability of lowered or otherwise generated code. This
commit works to implementing them to improve the mentioned hinderences.

Resolves llvm#70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Nov 21, 2023
We have missing basic constant folds for SPIR-V logical operations which
negatively impacts readability of lowered or otherwise generated code. This
commit works to implementing them to improve the mentioned hinderences.
Corrects some testcases in logical-ops-to-llvm as required.

Resolves llvm#70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Nov 24, 2023
Add missing constant propogation folder for IAddCarry and
[S|U]MulExtended. Due to currently missing constant value for
spirv.struct the folding is done using canonicalization patterns.

Implement additional folding when rhs is 0 for all ops and when rhs
is 1 for UMulExt.

This helps for readability of lowered code into SPIRV.

Part of work for llvm#70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Nov 24, 2023
Add missing constant propogation folder for [S|U]Mod, [S|U]Div, SRem

Implement additional folding when rhs is 1 for all ops.

This helps for readability of lowered code into SPIR-V.

Part of work for llvm#70704
kuhar pushed a commit that referenced this issue Nov 29, 2023
Add missing constant propogation folder for [S|U]Mod, [S|U]Div, SRem

Implement additional folding when rhs is 1 for all ops.

This helps for readability of lowered code into SPIR-V.

Part of work for #70704
kuhar pushed a commit that referenced this issue Nov 29, 2023
Add missing constant propogation folder for IAddCarry and
[S|U]MulExtended. Due to currently missing constant value for
spirv.struct the folding is done using canonicalization patterns.

Implement additional folding when rhs is 0 for all ops and when rhs is 1
for UMulExt.

This helps for readability of lowered code into SPIR-V.

Part of work for #70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Mar 15, 2024
Add missing constant propogation folder for [S|U]LessThan[Equal].

Implement additional folding when the operands are equal for all ops.

Allows for constant folding in the IndexToSPIRV pass.

Part of work llvm#70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Mar 15, 2024
Add missing constant propogation folder for spirv.Select

Implement additional folding when both selections are equivalent or the
condition is a constant Scalar/SplatVector.

Allows for constant folding in the IndexToSPIRV pass.

Part of work llvm#70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Mar 15, 2024
Add missing constant propogation folder for [S|U]GreaterThan[Equal].

Implement additional folding when the operands are equal for all ops.

Allows for constant folding in the IndexToSPIRV pass.

Part of work llvm#70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Mar 15, 2024
Add missing constant propogation folder for [S|U|GreaterThan[Equal].

Implement additional folding when the operands are equal for all ops.

Allows for constant folding in the IndexToSPIRV pass.

Part of work llvm#70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Mar 15, 2024
Add missing constant propogation folder for [S|U]LessThan[Equal].

Implement additional folding when the operands are equal for all ops.

Allows for constant folding in the IndexToSPIRV pass.

Part of work llvm#70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Mar 15, 2024
Add missing constant propogation folder for spirv.Select

Implement additional folding when both selections are equivalent or the
condition is a constant Scalar/SplatVector.

Allows for constant folding in the IndexToSPIRV pass.

Part of work llvm#70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Mar 15, 2024
Allow for constant propogation when converting from index to SPIR-V for:
ceildiv[s|u] and floordivs.

Aims to improve readability of generated SPIR-V code.

Part of work llvm#70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Mar 15, 2024
Investigate the lowering of MemRef Load/Store ops and implement
additional folding of created ops

Aims to improve readability of generated lowered SPIR-V code.

Part of work llvm#70704
inbelic added a commit that referenced this issue Mar 19, 2024
Add missing constant propogation folder for spirv.Select

Implement additional folding when both selections are equivalent or the
condition is a constant Scalar/SplatVector.

Allows for constant folding in the IndexToSPIRV pass.

Part of work #70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Mar 19, 2024
Investigate the lowering of MemRef Load/Store ops and implement
additional folding of created ops

Aims to improve readability of generated lowered SPIR-V code.

Part of work llvm#70704
inbelic added a commit that referenced this issue Mar 21, 2024
Investigate the lowering of MemRef Load/Store ops and implement
additional folding of created ops

Aims to improve readability of generated lowered SPIR-V code.

Part of work #70704
chencha3 pushed a commit to chencha3/llvm-project that referenced this issue Mar 23, 2024
Add missing constant propogation folder for spirv.Select

Implement additional folding when both selections are equivalent or the
condition is a constant Scalar/SplatVector.

Allows for constant folding in the IndexToSPIRV pass.

Part of work llvm#70704
chencha3 pushed a commit to chencha3/llvm-project that referenced this issue Mar 23, 2024
Investigate the lowering of MemRef Load/Store ops and implement
additional folding of created ops

Aims to improve readability of generated lowered SPIR-V code.

Part of work llvm#70704
inbelic added a commit that referenced this issue Mar 25, 2024
Add missing constant propogation folder for [S|U]LessThan[Equal].

Implement additional folding when the operands are equal for all ops.

Allows for constant folding in the IndexToSPIRV pass.

Part of work #70704
inbelic added a commit to inbelic/llvm-project that referenced this issue Mar 26, 2024
Add missing constant propogation folder for [S|U]GreaterThan[Equal].

Implement additional folding when the operands are equal for all ops.

Allows for constant folding in the IndexToSPIRV pass.

Part of work llvm#70704
inbelic added a commit that referenced this issue Mar 26, 2024
Add missing constant propogation folder for [S|U]GreaterThan[Equal].

Implement additional folding when the operands are equal for all ops.

Allows for constant folding in the IndexToSPIRV pass.

Part of work #70704
@kuhar
Copy link
Member

kuhar commented Aug 6, 2024

I think this has been completed, I'm not aware of any missing folds / canon rules

@kuhar kuhar closed this as completed Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants