From 9489806fa258b90b02b55804e61e9eb748724ce7 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Thu, 8 Oct 2020 11:41:00 +0200 Subject: [PATCH] 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. --- gcc/gimple-range.cc | 2 ++ 1 file changed, 2 insertions(+) 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; } -- 2.30.2