Revert "[Support] Don't include <algorithm> in MathExtras.h"
This reverts commit 6580d8a2b14d50b7e067dc86df6e5dd65703d147.
GitOrigin-RevId: af2a93fd6e9f9e037d2e2d67b879fe85d7e1cbed
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h
index 10d4260..640b3a1 100644
--- a/include/llvm/Support/MathExtras.h
+++ b/include/llvm/Support/MathExtras.h
@@ -14,6 +14,7 @@
#define LLVM_SUPPORT_MATHEXTRAS_H
#include "llvm/Support/Compiler.h"
+#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
@@ -792,7 +793,7 @@
/// value of the result.
template <typename T>
std::enable_if_t<std::is_unsigned<T>::value, T> AbsoluteDifference(T X, T Y) {
- return X > Y ? X - Y : Y - X;
+ return std::max(X, Y) - std::min(X, Y);
}
/// Add two unsigned integers, X and Y, of type T. Clamp the result to the