OSDN Git Service

[ConstantRange] Improve the efficiency of one of the ConstantRange constructors.
authorCraig Topper <craig.topper@gmail.com>
Sat, 29 Apr 2017 05:08:52 +0000 (05:08 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sat, 29 Apr 2017 05:08:52 +0000 (05:08 +0000)
commit8c828d31cefc281bb875fa5c7275f47892852723
treed02821acd5f62a5750eb79f13e781f4a420d436a
parent23450e59978bd3d88e0f2067928a6644bd2bc4c5
[ConstantRange] Improve the efficiency of one of the ConstantRange constructors.

We were default constructing the Lower/Upper APInts. Then creating min or max value, then doing a move assignment to Lower and copy assignment to upper. The copy assignment operator in particular has an out of line function call that has to examine whether or not a previous allocation exists that can be reused which of course it can't in this case.

The new code creates the min/max value first, move constructs Lower from it then copy constructs Upper from Lower.

This also seems to have convinced a self host build that this constructor can be inlined more readily into other methods in ConstantRange.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301736 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/ConstantRange.cpp