diff options
author | Justin Holewinski <jholewinski@nvidia.com> | 2014-06-27 19:36:25 +0000 |
---|---|---|
committer | Justin Holewinski <jholewinski@nvidia.com> | 2014-06-27 19:36:25 +0000 |
commit | 8474c35bd85e432f51cc920dc412c7342ce18fa4 (patch) | |
tree | aac60b67979e4628528bb2a1712585132604f0dc /lib | |
parent | 704fa86de5a76f93e6fadfa108d8fbd51c5e5726 (diff) | |
download | llvm-8474c35bd85e432f51cc920dc412c7342ce18fa4.tar.gz llvm-8474c35bd85e432f51cc920dc412c7342ce18fa4.tar.bz2 llvm-8474c35bd85e432f51cc920dc412c7342ce18fa4.tar.xz |
[NVPTX] Use GreatestCommonDivisor64 from MathExtras instead of using our own. Thanks Hal!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211952 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/NVPTX/NVPTXISelLowering.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/lib/Target/NVPTX/NVPTXISelLowering.cpp b/lib/Target/NVPTX/NVPTXISelLowering.cpp index 9160015009..82c6a77a89 100644 --- a/lib/Target/NVPTX/NVPTXISelLowering.cpp +++ b/lib/Target/NVPTX/NVPTXISelLowering.cpp @@ -33,6 +33,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include <sstream> @@ -67,17 +68,6 @@ static bool IsPTXVectorType(MVT VT) { } } -static uint64_t GCD( int a, int b) -{ - if (a < b) std::swap(a,b); - while (b > 0) { - uint64_t c = b; - b = a % b; - a = c; - } - return a; -} - /// ComputePTXValueVTs - For the given Type \p Ty, returns the set of primitive /// EVTs that compose it. Unlike ComputeValueVTs, this will break apart vectors /// into their primitive components. @@ -718,7 +708,7 @@ SDValue NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, InFlag = Chain.getValue(1); for (unsigned j = 0, je = vtparts.size(); j != je; ++j) { EVT elemtype = vtparts[j]; - unsigned ArgAlign = GCD(align, Offsets[j]); + unsigned ArgAlign = GreatestCommonDivisor64(align, Offsets[j]); if (elemtype.isInteger() && (sz < 8)) sz = 8; SDValue StVal = OutVals[OIdx]; @@ -943,7 +933,7 @@ SDValue NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, for (unsigned j = 0, je = vtparts.size(); j != je; ++j) { EVT elemtype = vtparts[j]; int curOffset = Offsets[j]; - unsigned PartAlign = GCD(ArgAlign, curOffset); + unsigned PartAlign = GreatestCommonDivisor64(ArgAlign, curOffset); SDValue srcAddr = DAG.getNode(ISD::ADD, dl, getPointerTy(), OutVals[OIdx], DAG.getConstant(curOffset, getPointerTy())); @@ -1204,7 +1194,7 @@ SDValue NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, unsigned RetAlign = getArgumentAlignment(Callee, CS, retTy, 0); for (unsigned i = 0, e = Ins.size(); i != e; ++i) { unsigned sz = VTs[i].getSizeInBits(); - unsigned AlignI = GCD(RetAlign, Offsets[i]); + unsigned AlignI = GreatestCommonDivisor64(RetAlign, Offsets[i]); bool needTruncate = sz < 8 ? true : false; if (VTs[i].isInteger() && (sz < 8)) sz = 8; |