Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: src/IceUtils.h

Issue 1318553003: Compute the loop nest depth of each CfgNode and weight Variables by it. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceTimerTree.def ('k') | tests_lit/llvm2ice_tests/loop-nest-depth.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceUtils.h
diff --git a/src/IceUtils.h b/src/IceUtils.h
index 6d65ade76379d4854825de8685e266bbd1c06310..f07a566b1c7954636d21f849a7e060b1b8efca9c 100644
--- a/src/IceUtils.h
+++ b/src/IceUtils.h
@@ -70,6 +70,18 @@ public:
(X < 0 && Y < 0 && (X < std::numeric_limits<T>::min() - Y)));
}
+ /// Adds x to y and stores the result in sum. Returns true if the addition
+ /// overflowed.
+ static inline bool add_overflow(uint32_t x, uint32_t y, uint32_t *sum) {
+ static_assert(std::is_same<uint32_t, unsigned>::value, "Must match type");
+#if __has_builtin(__builtin_uadd_overflow)
+ return __builtin_uadd_overflow(x, y, sum);
+#else
+ *sum = x + y;
+ return WouldOverflowAdd(x, y);
+#endif
+ }
+
/// Return true if X is already aligned by N, where N is a power of 2.
template <typename T> static inline bool IsAligned(T X, intptr_t N) {
assert(llvm::isPowerOf2_64(N));
« no previous file with comments | « src/IceTimerTree.def ('k') | tests_lit/llvm2ice_tests/loop-nest-depth.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698