Reland "[Support] Don't include <algorithm> in MathExtras.h"

This reverts commit af2a93fd6e9f9e037d2e2d67b879fe85d7e1cbed.
This time, add the include to APInt.h, which apparently relied
on getting this include transitively.

GitOrigin-RevId: 0b36a33ab89488a631d5ee9580904a36898c7954
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h
index b97ea2c..0fca6ba 100644
--- a/include/llvm/ADT/APInt.h
+++ b/include/llvm/ADT/APInt.h
@@ -17,6 +17,7 @@
 
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/MathExtras.h"
+#include <algorithm>
 #include <cassert>
 #include <climits>
 #include <cstring>
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h
index 640b3a1..10d4260 100644
--- a/include/llvm/Support/MathExtras.h
+++ b/include/llvm/Support/MathExtras.h
@@ -14,7 +14,6 @@
 #define LLVM_SUPPORT_MATHEXTRAS_H
 
 #include "llvm/Support/Compiler.h"
-#include <algorithm>
 #include <cassert>
 #include <climits>
 #include <cmath>
@@ -793,7 +792,7 @@
 /// value of the result.
 template <typename T>
 std::enable_if_t<std::is_unsigned<T>::value, T> AbsoluteDifference(T X, T Y) {
-  return std::max(X, Y) - std::min(X, Y);
+  return X > Y ? X - Y : Y - X;
 }
 
 /// Add two unsigned integers, X and Y, of type T.  Clamp the result to the