diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-06 21:44:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-06 21:44:57 +0000 |
commit | 35bda8914c0d1c02a6f90f42e7810c83150737e1 (patch) | |
tree | b210ccd009a7ac5331c76c6393b5b45d141d12d0 /lib/VMCore | |
parent | bd75021465e7f8c81785e692cfd3ce559764e46f (diff) | |
download | external_llvm-35bda8914c0d1c02a6f90f42e7810c83150737e1.zip external_llvm-35bda8914c0d1c02a6f90f42e7810c83150737e1.tar.gz external_llvm-35bda8914c0d1c02a6f90f42e7810c83150737e1.tar.bz2 |
enhance vmcore to know that udiv's can be exact, and add a trivial
instcombine xform to exercise this.
Nothing forms exact udivs yet though. This is progress on PR8862
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124992 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 3 | ||||
-rw-r--r-- | lib/VMCore/Constants.cpp | 7 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 4 |
3 files changed, 10 insertions, 4 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 1a11d9c..5b56cb5 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -831,7 +831,8 @@ static void WriteOptimizationInfo(raw_ostream &Out, const User *U) { Out << " nuw"; if (OBO->hasNoSignedWrap()) Out << " nsw"; - } else if (const SDivOperator *Div = dyn_cast<SDivOperator>(U)) { + } else if (const PossiblyExactOperator *Div = + dyn_cast<PossiblyExactOperator>(U)) { if (Div->isExact()) Out << " exact"; } else if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) { diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 62117b2..d2359e5 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -683,7 +683,12 @@ Constant* ConstantExpr::getNUWMul(Constant* C1, Constant* C2) { Constant* ConstantExpr::getExactSDiv(Constant* C1, Constant* C2) { return getTy(C1->getType(), Instruction::SDiv, C1, C2, - SDivOperator::IsExact); + PossiblyExactOperator::IsExact); +} + +Constant* ConstantExpr::getExactUDiv(Constant* C1, Constant* C2) { + return getTy(C1->getType(), Instruction::UDiv, C1, C2, + PossiblyExactOperator::IsExact); } // Utility function for determining if a ConstantExpr is a CastOp or not. This diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 6b561f3..d129028 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -1822,7 +1822,7 @@ void BinaryOperator::setHasNoSignedWrap(bool b) { } void BinaryOperator::setIsExact(bool b) { - cast<SDivOperator>(this)->setIsExact(b); + cast<PossiblyExactOperator>(this)->setIsExact(b); } bool BinaryOperator::hasNoUnsignedWrap() const { @@ -1834,7 +1834,7 @@ bool BinaryOperator::hasNoSignedWrap() const { } bool BinaryOperator::isExact() const { - return cast<SDivOperator>(this)->isExact(); + return cast<PossiblyExactOperator>(this)->isExact(); } //===----------------------------------------------------------------------===// |