summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-07-09 22:01:22 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-07-09 22:01:22 +0000
commita80fed7e581517d69f46815644585bdcedcdf726 (patch)
tree855fa938610a6df3d1c90f596672735a942dab0e /llvm/lib/Analysis/InstructionSimplify.cpp
parent1014fcfd9984b6d56e93e7d387061243e7f32a35 (diff)
downloadbcm5719-llvm-a80fed7e581517d69f46815644585bdcedcdf726.tar.gz
bcm5719-llvm-a80fed7e581517d69f46815644585bdcedcdf726.zip
InstSimplify: X >> X -> 0
llvm-svn: 185973
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index bf7745143da..d66ecca928a 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -1363,6 +1363,10 @@ static Value *SimplifyLShrInst(Value *Op0, Value *Op1, bool isExact,
if (Value *V = SimplifyShift(Instruction::LShr, Op0, Op1, Q, MaxRecurse))
return V;
+ // X >> X -> 0
+ if (Op0 == Op1)
+ return Constant::getNullValue(Op0->getType());
+
// undef >>l X -> 0
if (match(Op0, m_Undef()))
return Constant::getNullValue(Op0->getType());
@@ -1391,6 +1395,10 @@ static Value *SimplifyAShrInst(Value *Op0, Value *Op1, bool isExact,
if (Value *V = SimplifyShift(Instruction::AShr, Op0, Op1, Q, MaxRecurse))
return V;
+ // X >> X -> 0
+ if (Op0 == Op1)
+ return Constant::getNullValue(Op0->getType());
+
// all ones >>a X -> all ones
if (match(Op0, m_AllOnes()))
return Op0;
OpenPOWER on IntegriCloud