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][llvm] Add icmp folder #65343

Merged
merged 3 commits into from
Sep 6, 2023
Merged

[mlir][llvm] Add icmp folder #65343

merged 3 commits into from
Sep 6, 2023

Conversation

gysit
Copy link
Contributor

@gysit gysit commented Sep 5, 2023

This revision adds a simple icmp folder that performs the following folds to the LLVM dialect icmp op:

  • cmpi(eq/ne, x, x) -> true/false
  • cmpi(eq/ne, alloca, null) -> false/true
  • cmpi(eq/ne, null, alloca) -> cmpi(eq/ne, alloca, null)

This revision adds a simple icmp folder that performs the
following folds to the LLVM dialect icmp op:
 - cmpi(eq/ne, x, x) -> true/false
 - cmpi(eq/ne, alloca, null) -> false/true
 - cmpi(eq/ne, null, alloca) -> cmpi(eq/ne, alloca, null)
@gysit gysit requested a review from zero9178 September 5, 2023 16:02
@gysit gysit requested review from a team as code owners September 5, 2023 16:03
@github-actions github-actions bot added mlir:core MLIR Core Infrastructure mlir labels Sep 5, 2023
@zero9178
Copy link
Member

zero9178 commented Sep 5, 2023

Looks good!

Since you've gone through the effort of making this work with vector types as well, could you add at least one test that uses vector input types?

and update constant materialization to support vectors.
@gysit
Copy link
Contributor Author

gysit commented Sep 5, 2023

Good point, the constant materialization did indeed not support vectors!

Copy link
Member

@zero9178 zero9178 left a comment

Choose a reason for hiding this comment

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

LGTM!

/// Returns a scalar or vector boolean attribute of the given type.
static Attribute getBoolAttribute(Type type, MLIRContext *ctx, bool value) {
auto boolAttr = BoolAttr::get(ctx, value);
ShapedType shapedType = llvm::dyn_cast_or_null<ShapedType>(type);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ShapedType shapedType = llvm::dyn_cast_or_null<ShapedType>(type);
ShapedType shapedType = dyn_cast<ShapedType>(type);

@joker-eph joker-eph removed the request for review from a team September 5, 2023 20:18
@joker-eph
Copy link
Collaborator

Please don't use subscribers teams to request reviews

@zero9178
Copy link
Member

zero9178 commented Sep 5, 2023

Please don't use subscribers teams to request reviews

Could you elaborate what you mean? These are added automatically as they are code-owners of changed files. Isn't the intent of these teams being code-owners that they are automatically added as reviewers and members therefore notified?

@gysit gysit merged commit 0c81e6d into llvm:main Sep 6, 2023
avillega pushed a commit to avillega/llvm-project that referenced this pull request Sep 11, 2023
This revision adds a simple icmp folder that performs the following
folds to the LLVM dialect icmp op:
 - cmpi(eq/ne, x, x) -> true/false
 - cmpi(eq/ne, alloca, null) -> false/true
 - cmpi(eq/ne, null, alloca) -> cmpi(eq/ne, alloca, null)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants