summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorChen Zheng <shchenz@cn.ibm.com>2018-07-20 13:00:47 +0000
committerChen Zheng <shchenz@cn.ibm.com>2018-07-20 13:00:47 +0000
commitf801d0fea944487132c23dd4c5de58b9b4fbecf0 (patch)
treed0eba193a8505aac54010e715b454193c3c40859 /llvm/lib/Analysis/InstructionSimplify.cpp
parentf9adc20aeff83ddb07b3b741099bf441425b787c (diff)
downloadbcm5719-llvm-f801d0fea944487132c23dd4c5de58b9b4fbecf0.tar.gz
bcm5719-llvm-f801d0fea944487132c23dd4c5de58b9b4fbecf0.zip
[InstSimplify] fold srem instruction if its two operands are negated.
Differential Revision: https://reviews.llvm.org/D49423 llvm-svn: 337545
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 2eed5fc6418..e095e95935b 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -1109,6 +1109,10 @@ static Value *SimplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
if (match(Op1, m_SExt(m_Value(X))) && X->getType()->isIntOrIntVectorTy(1))
return ConstantInt::getNullValue(Op0->getType());
+ // If the two operands are negated, return 0.
+ if (isKnownNegation(Op0, Op1))
+ return ConstantInt::getNullValue(Op0->getType());
+
return simplifyRem(Instruction::SRem, Op0, Op1, Q, MaxRecurse);
}
OpenPOWER on IntegriCloud