]> granicus.if.org Git - llvm/commitdiff
InstructionSimplify: Simplify a shuffle with a undef mask to undef
authorZvi Rackover <zvi.rackover@intel.com>
Sun, 30 Apr 2017 06:06:26 +0000 (06:06 +0000)
committerZvi Rackover <zvi.rackover@intel.com>
Sun, 30 Apr 2017 06:06:26 +0000 (06:06 +0000)
Summary:
Following the discussion in pr32486, adding the simplification:
 shuffle %x, %y, undef -> undef

Reviewers: spatel, RKSimon, andreadb, davide

Reviewed By: spatel

Subscribers: jroelofs, davide, llvm-commits

Differential Revision: https://reviews.llvm.org/D32293

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301764 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 800382079c1672e0c653fe421a3ede61af99db94..d753c47ef6d4c2046eda9640ff43755298146512 100644 (file)
@@ -4049,6 +4049,9 @@ static Value *foldIdentityShuffles(int DestElt, Value *Op0, Value *Op1,
 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();
index e03916c5b90d6eca8300436b28df64d2e5201500..6af0db8e5a442bfa461e934052c420ff9c26373a 100644 (file)
@@ -118,6 +118,14 @@ define <4 x i32> @undef_mask(<4 x i32> %x) {
   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:%.*]]