Skip to content

[PatternMatch] m_SpecificMask should pass expected mask by Value. NFC #121527

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
Jan 3, 2025

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Jan 2, 2025

Unlike m_Mask, we don't need to modify a variable owned by the caller so we should pass the ArrayRef by value or const reference.

Unlike m_Mask, we don't need to modify a variable owned by the caller
so we should pass the ArrayRef by value or const reference.
@llvmbot
Copy link
Member

llvmbot commented Jan 2, 2025

@llvm/pr-subscribers-llvm-ir

Author: Craig Topper (topperc)

Changes

Unlike m_Mask, we don't need to modify a variable owned by the caller so we should pass the ArrayRef by value or const reference.


Full diff: https://github.com/llvm/llvm-project/pull/121527.diff

1 Files Affected:

  • (modified) llvm/include/llvm/IR/PatternMatch.h (+3-3)
diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h
index cc0e8d598ff1ea..b37f967191aaa8 100644
--- a/llvm/include/llvm/IR/PatternMatch.h
+++ b/llvm/include/llvm/IR/PatternMatch.h
@@ -1844,9 +1844,9 @@ struct m_ZeroMask {
 };
 
 struct m_SpecificMask {
-  ArrayRef<int> &MaskRef;
-  m_SpecificMask(ArrayRef<int> &MaskRef) : MaskRef(MaskRef) {}
-  bool match(ArrayRef<int> Mask) { return MaskRef == Mask; }
+  ArrayRef<int> Val;
+  m_SpecificMask(ArrayRef<int> Val) : Val(Val) {}
+  bool match(ArrayRef<int> Mask) { return Val == Mask; }
 };
 
 struct m_SplatOrPoisonMask {

Copy link
Member

@mshockwave mshockwave left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

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

LGTM

@topperc topperc merged commit c19f0f0 into llvm:main Jan 3, 2025
10 checks passed
@topperc topperc deleted the pr/specificmask branch January 3, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants