Skip to content

Commit 04f33a3

Browse files
authored
[APInt] Use a std::move() to avoid a copy in the loop in multiplicativeInverse. (#87655)
This allows the subtract to reuse the storage of T. T will be assigned over by the condition on the next iteration. I think assigning over a moved from value should be ok.
1 parent 74c085f commit 04f33a3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Support/APInt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ APInt APInt::multiplicativeInverse() const {
12491249
APInt Factor = *this;
12501250
APInt T;
12511251
while (!(T = *this * Factor).isOne())
1252-
Factor *= 2 - T;
1252+
Factor *= 2 - std::move(T);
12531253
return Factor;
12541254
}
12551255

0 commit comments

Comments
 (0)