[PATCH] D136256: [InstCombine] Fix assert condition in `foldSelectShuffleOfSelectShuffle`

Nabeel Omer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 20 05:11:29 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGe1fd6d49a3df: [InstCombine] Fix assert condition in `foldSelectShuffleOfSelectShuffle` (authored by n-omer).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136256/new/

https://reviews.llvm.org/D136256

Files:
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/test/Transforms/InstCombine/shuffle_select.ll


Index: llvm/test/Transforms/InstCombine/shuffle_select.ll
===================================================================
--- llvm/test/Transforms/InstCombine/shuffle_select.ll
+++ llvm/test/Transforms/InstCombine/shuffle_select.ll
@@ -1621,3 +1621,13 @@
   %s2 = shufflevector <4 x i32> %s1, <4 x i32> %x, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
   ret <4 x i32> %s2
 }
+
+define <4 x float> @identity_mask(<4 x float>%x, <4 x float> %y) {
+; CHECK-LABEL: @identity_mask(
+; CHECK-NEXT:    [[S2:%.*]] = shufflevector <4 x float> [[X:%.*]], <4 x float> poison, <4 x i32> <i32 0, i32 undef, i32 2, i32 3>
+; CHECK-NEXT:    ret <4 x float> [[S2]]
+;
+  %s1 = shufflevector <4 x float> %x, <4 x float> %y, <4 x i32> <i32 0, i32 5, i32 undef, i32 undef>
+  %s2 = shufflevector <4 x float> %s1, <4 x float> %x, <4 x i32> <i32 0, i32 undef, i32 6, i32 7>
+  ret <4 x float> %s2
+}
Index: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2004,7 +2004,10 @@
   for (unsigned i = 0; i != NumElts; ++i)
     NewMask[i] = Mask[i] < (signed)NumElts ? Mask[i] : Mask1[i];
 
-  assert(ShuffleVectorInst::isSelectMask(NewMask) && "Unexpected shuffle mask");
+  // A select mask with undef elements might look like an identity mask.
+  assert((ShuffleVectorInst::isSelectMask(NewMask) ||
+          ShuffleVectorInst::isIdentityMask(NewMask)) &&
+         "Unexpected shuffle mask");
   return new ShuffleVectorInst(X, Y, NewMask);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136256.469174.patch
Type: text/x-patch
Size: 1626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221020/53f74e21/attachment.bin>


More information about the llvm-commits mailing list