From: Zvi Rackover Date: Sun, 30 Apr 2017 06:06:26 +0000 (+0000) Subject: InstructionSimplify: Simplify a shuffle with a undef mask to undef X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=778f5177f015657acfe30acfefac76f873faddba;p=llvm InstructionSimplify: Simplify a shuffle with a undef mask to undef 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 --- diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index 800382079c1..d753c47ef6d 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -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(Mask)) + return UndefValue::get(RetTy); + Type *InVecTy = Op0->getType(); unsigned MaskNumElts = Mask->getType()->getVectorNumElements(); unsigned InVecNumElts = InVecTy->getVectorNumElements(); diff --git a/test/Transforms/InstSimplify/shufflevector.ll b/test/Transforms/InstSimplify/shufflevector.ll index e03916c5b90..6af0db8e5a4 100644 --- a/test/Transforms/InstSimplify/shufflevector.ll +++ b/test/Transforms/InstSimplify/shufflevector.ll @@ -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:%.*]]