Skip to content

[CIR] Improved cir::CastOp verifier to allow bitcasts between types of the same size #1728

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

Merged
merged 1 commit into from
Jul 2, 2025

Conversation

tommymcm
Copy link
Contributor

@tommymcm tommymcm commented Jul 2, 2025

The cir::CastOp::verify method was overly conservative, and would fail on any bitcast from vector to scalar or scalar to vector.

Change List:

  • Extends the cir::CastOp::verify method to check if the source and result types are the same size using the mlir::DataLayout of the current scope, and succeeds if the sizes match.
  • Extends the CodeGen vectype tests with vector to scalar, scalar to vector and vector to vector conversions.
  • Extends the IR invalid tests with vector to scalar and scalar to vector conversions with different source and result sizes.

… of the same size.

The `cir::CastOp::verify` method was overly conservative, and would fail on any `bitcast` from vector to scalar or scalar to vector.
This diff extends the `cir::CastOp::verify` method to check if the source and result types are the same size using the `mlir::DataLayout` of the current scope, and succeeds if the sizes match.
This diff also extends the CodeGen vectype tests with vector to scalar, scalar to vector and vector to vector conversions.
This diff also extends the IR invalid tests with vector to scalar and scalar to vector	conversions with different source and result sizes.
Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks Tommy!

@bcardosolopes bcardosolopes merged commit 60da1a4 into llvm:main Jul 2, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants