]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
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 75c03d6610b7f28f9b0913f7aa73bd25bd6f4759..2461bb78394c592f3a46da9fb8631479379ce994 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;
        }