summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-06-26 17:31:38 +0000
committerSanjay Patel <spatel@rotateright.com>2018-06-26 17:31:38 +0000
commitad0bfb844d571af413c74bfcc19ce9d13f04d907 (patch)
tree6eb977a85a715362f20ec4eefef24b0a685b6898 /llvm/lib/Analysis/InstructionSimplify.cpp
parent91433f6877482a71fe3d04735d69b107a53edd26 (diff)
downloadbcm5719-llvm-ad0bfb844d571af413c74bfcc19ce9d13f04d907.tar.gz
bcm5719-llvm-ad0bfb844d571af413c74bfcc19ce9d13f04d907.zip
[InstSimplify] fold shifts by sext bool
https://rise4fun.com/Alive/c3Y llvm-svn: 335633
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 4a80558dd1b..c15f649e9c4 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -1162,7 +1162,11 @@ static Value *SimplifyShift(Instruction::BinaryOps Opcode, Value *Op0,
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.
OpenPOWER on IntegriCloud