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

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 16:25:38 PST 2023


https://github.com/rnk created https://github.com/llvm/llvm-project/pull/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.

>From 5933d1bea8e965428bc9abee6c42eb900936852b Mon Sep 17 00:00:00 2001
From: Reid Kleckner <rnk at google.com>
Date: Fri, 15 Dec 2023 00:14:01 +0000
Subject: [PATCH] [IR] Fix UB on Op<2> in ShuffleVector predicates

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.
---
 llvm/lib/IR/Instructions.cpp | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

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



More information about the llvm-commits mailing list