File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -5296,7 +5296,7 @@ impl Function {
52965296 }
52975297 Insn :: AdjustBounds { index, .. } => {
52985298 // If index is known nonnegative, then we don't need to adjust bounds.
5299- if self . type_of ( index) . cint64_value ( ) . filter ( | & i| i >= 0 ) . is_some ( ) {
5299+ if self . type_of ( index) . known_nonnegative ( ) {
53005300 self . make_equal_to ( insn_id, index) ;
53015301 // Don't bother re-inferring the type of index; we already know it.
53025302 continue ;
Original file line number Diff line number Diff line change @@ -411,6 +411,19 @@ impl Type {
411411 }
412412 }
413413
414+ fn int_spec_signed ( & self ) -> Option < i64 > {
415+ assert ! ( self . is_subtype( types:: CSigned ) , "int_spec_signed() only makes sense for signed integer types" ) ;
416+ match self . spec {
417+ Specialization :: Int ( val) => Some ( val as i64 ) ,
418+ _ => None ,
419+ }
420+ }
421+
422+ pub fn known_nonnegative ( & self ) -> bool {
423+ assert ! ( self . is_subtype( types:: CSigned ) , "nonnegative() only makes sense for signed integer types" ) ;
424+ self . int_spec_signed ( ) . map_or ( false , |val| val >= 0 )
425+ }
426+
414427 /// Return true if the Type has object specialization and false otherwise.
415428 pub fn ruby_object_known ( & self ) -> bool {
416429 matches ! ( self . spec, Specialization :: Object ( _) )
You can’t perform that action at this time.
0 commit comments