From: Aldy Hernandez Date: Thu, 8 Oct 2020 09:41:00 +0000 (+0200) Subject: Fix PR97325. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9489806fa258b90b02b55804e61e9eb748724ce7;p=gcc.git Fix PR97325. gcc/ChangeLog: PR tree-optimization/97325 * gimple-range.cc (gimple_ranger::range_of_builtin_call): Handle negative numbers in __builtin_ffs and __builtin_popcount. --- diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index 75c03d6610b..2461bb78394 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -620,6 +620,8 @@ gimple_ranger::range_of_builtin_call (irange &r, gcall *call) // If some high bits are known to be zero, decrease the maximum. if (!r.undefined_p ()) { + if (TYPE_SIGN (r.type ()) == SIGNED) + range_cast (r, unsigned_type_for (r.type ())); wide_int max = r.upper_bound (); maxi = wi::floor_log2 (max) + 1; }