File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1581,6 +1581,24 @@ def testfunc(n):
15811581 self .assertNotIn ("_COMPARE_OP_INT" , uops )
15821582 self .assertIn ("_POP_TWO_LOAD_CONST_INLINE_BORROW" , uops )
15831583
1584+ def test_remove_guard_for_known_type_str (self ):
1585+ def f (n ):
1586+ for i in range (n ):
1587+ false = i == TIER2_THRESHOLD
1588+ empty = "X" [:false ]
1589+ empty += "" # Make JIT realize this is a string.
1590+ if empty :
1591+ return 1
1592+ return 0
1593+
1594+ res , ex = self ._run_with_optimizer (f , TIER2_THRESHOLD )
1595+ self .assertEqual (res , 0 )
1596+ self .assertIsNotNone (ex )
1597+ uops = get_opnames (ex )
1598+ self .assertIn ("_TO_BOOL_STR" , uops )
1599+ self .assertNotIn ("_GUARD_TOS_UNICODE" , uops )
1600+
1601+
15841602def global_identity (x ):
15851603 return x
15861604
You can’t perform that action at this time.
0 commit comments