Fix PR97325.
authorAldy Hernandez <aldyh@redhat.com>
Thu, 8 Oct 2020 09:41:00 +0000 (11:41 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Thu, 8 Oct 2020 09:41:00 +0000 (11:41 +0200)
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

index 75c03d6..2461bb7 100644 (file)
@@ -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;
        }