From f801d0fea944487132c23dd4c5de58b9b4fbecf0 Mon Sep 17 00:00:00 2001 From: Chen Zheng Date: Fri, 20 Jul 2018 13:00:47 +0000 Subject: [InstSimplify] fold srem instruction if its two operands are negated. Differential Revision: https://reviews.llvm.org/D49423 llvm-svn: 337545 --- llvm/lib/Analysis/InstructionSimplify.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib') 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); } -- cgit v1.2.3