diff options
author | Anton Bikineev <ant.bikineev@gmail.com> | 2018-01-23 09:27:47 +0000 |
---|---|---|
committer | Anton Bikineev <ant.bikineev@gmail.com> | 2018-01-23 09:27:47 +0000 |
commit | 82f61151b377f59d667e9943d480c429c4d3e176 (patch) | |
tree | 5476d7557d269e8f50b9431f9739381537a80a00 /llvm/lib/Analysis/InstructionSimplify.cpp | |
parent | acc48f3e1dbd2742d2f61958ca484496e1210c62 (diff) | |
download | bcm5719-llvm-82f61151b377f59d667e9943d480c429c4d3e176.tar.gz bcm5719-llvm-82f61151b377f59d667e9943d480c429c4d3e176.zip |
[InstSimplify] (X << Y) % X -> 0
llvm-svn: 323182
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 6c6b1cfe720..245133fb912 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -1040,6 +1040,13 @@ static Value *simplifyRem(Instruction::BinaryOps Opcode, Value *Op0, Value *Op1, match(Op0, m_URem(m_Value(), m_Specific(Op1))))) return Op0; + // (X << Y) % X -> 0 + if ((Opcode == Instruction::SRem && + match(Op0, m_NSWShl(m_Specific(Op1), m_Value()))) || + (Opcode == Instruction::URem && + match(Op0, m_NUWShl(m_Specific(Op1), m_Value())))) + return Constant::getNullValue(Op0->getType()); + // If the operation is with the result of a select instruction, check whether // operating on either branch of the select always yields the same value. if (isa<SelectInst>(Op0) || isa<SelectInst>(Op1)) |