[PUSHED] Fix PR97325

Aldy Hernandez aldyh@redhat.com
Thu Oct 8 09:46:36 GMT 2020


This was a pasto by yours truly while porting the __builtin code from 
vr_values::extract_range_basic.

I've tested Andrew's patch, and pushed it.

Aldy

     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;
  	}



More information about the Gcc-patches mailing list