Skip to content

[IR] Fix UB on Op<2> in ShuffleVector predicates #75549

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
Dec 15, 2023
Merged

Conversation

rnk
Copy link
Collaborator

@rnk rnk commented Dec 15, 2023

This Op<2> usage was missed in 1ee6ec2, which replaced the third shuffle operand with a vector of integer mask constants.

I noticed this when attempting to make changes to the layout of llvm::Value.

This Op<2> usage was missed in 1ee6ec2, which replaced the third
shuffle operand with a vector of integer mask constants.

I noticed this when attempting to make changes to the layout of
llvm::Value.
@llvmbot
Copy link
Member

llvmbot commented Dec 15, 2023

@llvm/pr-subscribers-llvm-ir

Author: Reid Kleckner (rnk)

Changes

This Op<2> usage was missed in 1ee6ec2, which replaced the third shuffle operand with a vector of integer mask constants.

I noticed this when attempting to make changes to the layout of llvm::Value.


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

1 Files Affected:

  • (modified) llvm/lib/IR/Instructions.cpp (+1-8)
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index bc228a577c6a6c..299b4e74677dcc 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -2412,9 +2412,6 @@ bool ShuffleVectorInst::isInsertSubvectorMask(ArrayRef<int> Mask,
 }
 
 bool ShuffleVectorInst::isIdentityWithPadding() const {
-  if (isa<UndefValue>(Op<2>()))
-    return false;
-
   // FIXME: Not currently possible to express a shuffle mask for a scalable
   // vector for this case.
   if (isa<ScalableVectorType>(getType()))
@@ -2439,9 +2436,6 @@ bool ShuffleVectorInst::isIdentityWithPadding() const {
 }
 
 bool ShuffleVectorInst::isIdentityWithExtract() const {
-  if (isa<UndefValue>(Op<2>()))
-    return false;
-
   // FIXME: Not currently possible to express a shuffle mask for a scalable
   // vector for this case.
   if (isa<ScalableVectorType>(getType()))
@@ -2457,8 +2451,7 @@ bool ShuffleVectorInst::isIdentityWithExtract() const {
 
 bool ShuffleVectorInst::isConcat() const {
   // Vector concatenation is differentiated from identity with padding.
-  if (isa<UndefValue>(Op<0>()) || isa<UndefValue>(Op<1>()) ||
-      isa<UndefValue>(Op<2>()))
+  if (isa<UndefValue>(Op<0>()) || isa<UndefValue>(Op<1>()))
     return false;
 
   // FIXME: Not currently possible to express a shuffle mask for a scalable

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

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

LGTM

@rnk rnk merged commit 04b8c83 into llvm:main Dec 15, 2023
@rnk
Copy link
Collaborator Author

rnk commented Dec 15, 2023

It occurs to me that there's a missed opportunity to add some kind of bounds check assertion to the static index Op<> accessor helpers.

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.

3 participants