[PATCH] D32293: InstructionSimplify: Simplify a shuffle with a undef mask to undef

Zvi Rackover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 29 23:18:13 PDT 2017


zvi updated this revision to Diff 97209.
zvi added a comment.

Rebase on top of trunk


https://reviews.llvm.org/D32293

Files:
  lib/Analysis/InstructionSimplify.cpp
  test/Transforms/InstSimplify/shufflevector.ll


Index: test/Transforms/InstSimplify/shufflevector.ll
===================================================================
--- test/Transforms/InstSimplify/shufflevector.ll
+++ test/Transforms/InstSimplify/shufflevector.ll
@@ -118,6 +118,14 @@
   ret <4 x i32> %shuf
 }
 
+define <4 x i32> @undef_mask_1(<4 x i32> %x, <4 x i32> %y) {
+; CHECK-LABEL: @undef_mask_1(
+; CHECK-NEXT:    ret <4 x i32> undef
+;
+  %shuf = shufflevector <4 x i32> %x, <4 x i32> %y, <4 x i32> undef
+  ret <4 x i32> %shuf
+}
+
 define <4 x i32> @identity_mask_0(<4 x i32> %x) {
 ; CHECK-LABEL: @identity_mask_0(
 ; CHECK-NEXT:    ret <4 x i32> [[X:%.*]]
Index: lib/Analysis/InstructionSimplify.cpp
===================================================================
--- lib/Analysis/InstructionSimplify.cpp
+++ lib/Analysis/InstructionSimplify.cpp
@@ -4049,6 +4049,9 @@
 static Value *SimplifyShuffleVectorInst(Value *Op0, Value *Op1, Constant *Mask,
                                         Type *RetTy, const SimplifyQuery &Q,
                                         unsigned MaxRecurse) {
+  if (isa<UndefValue>(Mask))
+    return UndefValue::get(RetTy);
+
   Type *InVecTy = Op0->getType();
   unsigned MaskNumElts = Mask->getType()->getVectorNumElements();
   unsigned InVecNumElts = InVecTy->getVectorNumElements();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32293.97209.patch
Type: text/x-patch
Size: 1297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170430/1a4e5b9a/attachment.bin>


More information about the llvm-commits mailing list