[InstSimplify] fold shifts by sext bool
https://rise4fun.com/Alive/c3Y
llvm-svn: 335633
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 4a80558..c15f649 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -1162,7 +1162,11 @@
return Constant::getNullValue(Op0->getType());
// X shift by 0 -> X
- if (match(Op1, m_Zero()))
+ // Shift-by-sign-extended bool must be shift-by-0 because shift-by-all-ones
+ // would be poison.
+ Value *X;
+ if (match(Op1, m_Zero()) ||
+ (match(Op1, m_SExt(m_Value(X))) && X->getType()->isIntOrIntVectorTy(1)))
return Op0;
// Fold undefined shifts.