[InstCombine] drop poison flags when shuffle mask undef propagates to constant
llvm-svn: 336679
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index 16b057c..f317252 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -1223,6 +1223,11 @@
// shuf X, (bop X, C), M --> bop X, C'
Instruction *NewBO = BinaryOperator::Create(BOpcode, X, NewC);
NewBO->copyIRFlags(BO);
+
+ // An undef shuffle mask element may propagate as an undef constant element in
+ // the new binop. That would produce poison where the original code might not.
+ if (Mask->containsUndefElement())
+ NewBO->dropPoisonGeneratingFlags();
return NewBO;
}