Index: lib/Analysis/InstructionSimplify.cpp =================================================================== --- lib/Analysis/InstructionSimplify.cpp +++ lib/Analysis/InstructionSimplify.cpp @@ -4144,6 +4144,9 @@ auto *Op0Const = dyn_cast(Op0); auto *Op1Const = dyn_cast(Op1); + if (isa(Mask)) + return UndefValue::get(RetTy); + // If all operands are constant, constant fold the shuffle. if (Op0Const && Op1Const) return ConstantFoldShuffleVectorInstruction(Op0Const, Op1Const, Mask); 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:%.*]]