summaryrefslogtreecommitdiff
path: root/compiler/optimizing/induction_var_range.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing/induction_var_range.cc')
-rw-r--r--compiler/optimizing/induction_var_range.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/optimizing/induction_var_range.cc b/compiler/optimizing/induction_var_range.cc
index 2f5a22ec0e..1fa2724641 100644
--- a/compiler/optimizing/induction_var_range.cc
+++ b/compiler/optimizing/induction_var_range.cc
@@ -48,10 +48,11 @@ static bool IsSafeDiv(int32_t c1, int32_t c2) {
/** Computes a * b for a,b > 0 (at least until first overflow happens). */
static int64_t SafeMul(int64_t a, int64_t b, /*out*/ bool* overflow) {
- if (a > 0 && b > 0 && a > (std::numeric_limits<int64_t>::max() / b)) {
+ int64_t result;
+ if (__builtin_mul_overflow(a, b, &result)) {
*overflow = true;
}
- return a * b;
+ return result;
}
/** Returns b^e for b,e > 0. Sets overflow if arithmetic wrap-around occurred. */