[llvm] 04b8c83 - [IR] Fix UB on Op<2> in ShuffleVector predicates (#75549)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 15 08:20:07 PST 2023


Author: Reid Kleckner
Date: 2023-12-15T08:20:03-08:00
New Revision: 04b8c830d39b2c1d98bb4dee06de2cd26b4b89f9

URL: https://github.com/llvm/llvm-project/commit/04b8c830d39b2c1d98bb4dee06de2cd26b4b89f9
DIFF: https://github.com/llvm/llvm-project/commit/04b8c830d39b2c1d98bb4dee06de2cd26b4b89f9.diff

LOG: [IR] Fix UB on Op<2> in ShuffleVector predicates (#75549)

This Op<2> usage was missed in 1ee6ec2bf3, 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.

Added: 
    

Modified: 
    llvm/lib/IR/Instructions.cpp

Removed: 
    


################################################################################
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 
diff erentiated 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


        


More information about the llvm-commits mailing list