]> granicus.if.org Git - llvm/commit
[APInt] Allow GreatestCommonDivisor to take rvalue inputs efficiently. Use moves...
authorCraig Topper <craig.topper@gmail.com>
Sat, 1 Apr 2017 20:30:57 +0000 (20:30 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sat, 1 Apr 2017 20:30:57 +0000 (20:30 +0000)
commit2ea3d99e26057f64006769a0777d59c4e26f28f5
treed2aecff4d31245b2adb830e5b63038b6780b2656
parent084c1ea3b411594e74d9e080c2cdf8d123407e79
[APInt] Allow GreatestCommonDivisor to take rvalue inputs efficiently. Use moves instead of copies in the loop.

Summary:
GreatestComonDivisor currently makes a copy of both its inputs. Then in the loop we do one move and two copies, plus any allocation the urem call does.

This patch changes it to take its inputs by value so that we can do a move of any rvalue inputs instead of copying. Then in the loop we do 3 move assignments and no copies. This way the only possible allocations we have in the loop is from the urem call.

Reviewers: dblaikie, RKSimon, hans

Reviewed By: dblaikie

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31572

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299314 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/APInt.h
lib/Support/APInt.cpp