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

[WIP] dialects: (arith) Fix arith.constant to return only signless integers #3802

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

compor
Copy link
Collaborator

@compor compor commented Jan 29, 2025

This PR:

  • Fixes arith.constant to return only signless integers
  • Adds tests of the above

Resolves #1101

cc @n-io @dk949
A side effect of this is that some of CSL backend tests are broken, as they use arith.constant to generate signed and unsigned integers for various bit widths.

I've fixed print_csl.mlir by adding csl.mlir.signedness_casts which creates benign(?) artifacts of @as(i32, 100) vs plain 100. I'm hoping these are essentially optimized away by the CSL compiler/SDK, but I couldn't find anything related by a cursory look in the docs.

More involved fixes would be need in the CSL canonicalization patterns, as they explicitly check for the existence of arith.constant ops.

@superlopuh my suggestion would be for the CSL ppl to create a separate PR to fix these before this going in, not sure if you agree.

Failing filecheck tests:

dialects/csl/csl-canonicalize.mlir
transforms/csl-stencil-handle-async-flow.mlir
transforms/memref-to-dsd.mlir

@compor compor added the dialects Changes on the dialects label Jan 29, 2025
@compor compor requested review from superlopuh, n-io and dk949 January 29, 2025 13:42
@compor compor self-assigned this Jan 29, 2025
@compor compor marked this pull request as draft January 29, 2025 13:43
@superlopuh
Copy link
Member

I'm a bit confused by the "fix", why is this desirable?

@compor
Copy link
Collaborator Author

compor commented Jan 29, 2025

I'm a bit confused by the "fix", why is this desirable?

What fix are you referring to? The arith or the CSL part?

If it is for arith, then arith.constant 0 : si32 is not valid IR.

@compor
Copy link
Collaborator Author

compor commented Jan 29, 2025

xdsl/dialects/arith.py Outdated Show resolved Hide resolved
compor added a commit that referenced this pull request Jan 30, 2025
This PR to de-indents tests by removing the implicitly added
`builtin.module`.

@superlopuh I applied my script to similar files within that test
subfolder while at it.

As discussed
[here](#3802 (comment)).
@compor compor force-pushed the christos/dialects/arith/constant-signless-bug-fix branch from 34e7293 to ab1834d Compare January 30, 2025 13:06
@compor
Copy link
Collaborator Author

compor commented Feb 4, 2025

@n-io @dk949 any thoughts on this wrt the CSL changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialects Changes on the dialects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dialects: (arith) arith.constant verifies non-signless types.
3 participants