summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-09-17 03:34:34 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-09-17 03:34:34 +0000
commitac717f0972b7bb1a138bbf3fdd7dd282462c6d49 (patch)
tree90e0f08d410de8a9655a1f7c920be6e8f60b1204 /llvm/lib/Analysis/InstructionSimplify.cpp
parent85d5e6f25b4b8439e1fada9c2c46e9ab78bbb813 (diff)
downloadbcm5719-llvm-ac717f0972b7bb1a138bbf3fdd7dd282462c6d49.tar.gz
bcm5719-llvm-ac717f0972b7bb1a138bbf3fdd7dd282462c6d49.zip
InstSimplify: ((X % Y) % Y) -> (X % Y)
Patch by Sonam Kumari! Differential Revision: http://reviews.llvm.org/D5350 llvm-svn: 217937
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index a745d14ca42..039d8286ecb 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -1171,6 +1171,11 @@ static Value *SimplifyRem(Instruction::BinaryOps Opcode, Value *Op0, Value *Op1,
if (Op0 == Op1)
return Constant::getNullValue(Op0->getType());
+ // ((X % Y) % Y) -> (X % Y)
+ if (match(Op0, m_SRem(m_Value(), m_Specific(Op1)))) {
+ return Op0;
+ }
+
// 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))
OpenPOWER on IntegriCloud