From 5747abab10b00a7f84458cc3fb41715b4790239a Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Wed, 2 Feb 2011 20:52:00 +0000 Subject: Reenable the transform "(X*Y)/Y->X" when the multiplication is known not to overflow (nsw flag), which was disabled because it breaks 254.gap. I have informed the GAP authors of the mistake in their code, and arranged for the testsuite to use -fwrapv when compiling this benchmark. llvm-svn: 124746 --- llvm/lib/Analysis/InstructionSimplify.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Analysis') diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 6ca4dddcf36..4b9b648aa6c 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -798,11 +798,11 @@ static Value *SimplifyDiv(unsigned Opcode, Value *Op0, Value *Op1, Value *X = 0, *Y = 0; if (match(Op0, m_Mul(m_Value(X), m_Value(Y))) && (X == Op1 || Y == Op1)) { if (Y != Op1) std::swap(X, Y); // Ensure expression is (X * Y) / Y, Y = Op1 -// BinaryOperator *Mul = cast(Op0); -// // If the Mul knows it does not overflow, then we are good to go. -// if ((isSigned && Mul->hasNoSignedWrap()) || -// (!isSigned && Mul->hasNoUnsignedWrap())) -// return X; + BinaryOperator *Mul = cast(Op0); + // If the Mul knows it does not overflow, then we are good to go. + if ((isSigned && Mul->hasNoSignedWrap()) || + (!isSigned && Mul->hasNoUnsignedWrap())) + return X; // If X has the form X = A / Y then X * Y cannot overflow. if (BinaryOperator *Div = dyn_cast(X)) if (Div->getOpcode() == Opcode && Div->getOperand(1) == Y) -- cgit v1.2.3