diff options
author | David Majnemer <david.majnemer@gmail.com> | 2013-07-09 22:01:22 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2013-07-09 22:01:22 +0000 |
commit | 8c5c6f0e090f91b6555cdd9d2eea238fff3befe6 (patch) | |
tree | 8d3a93378e1e1c3c148122b14136a9c685ca9891 /lib | |
parent | e4e742a62d5efa8f69b351dde87f9a20c03503ef (diff) | |
download | external_llvm-8c5c6f0e090f91b6555cdd9d2eea238fff3befe6.zip external_llvm-8c5c6f0e090f91b6555cdd9d2eea238fff3befe6.tar.gz external_llvm-8c5c6f0e090f91b6555cdd9d2eea238fff3befe6.tar.bz2 |
InstSimplify: X >> X -> 0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185973 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/InstructionSimplify.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index bf77451..d66ecca 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/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; |