File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1481,6 +1481,30 @@ def fn(a):
14811481
14821482 fn (A ())
14831483
1484+ def test_func_guards_removed_or_reduced (self ):
1485+ def testfunc (n ):
1486+ for i in range (n ):
1487+ # Only works on functions promoted to constants
1488+ global_identity (i )
1489+
1490+ opt = _testinternalcapi .new_uop_optimizer ()
1491+ with temporary_optimizer (opt ):
1492+ testfunc (20 )
1493+
1494+ ex = get_first_executor (testfunc )
1495+ self .assertIsNotNone (ex )
1496+ uops = get_opnames (ex )
1497+ self .assertIn ("_PUSH_FRAME" , uops )
1498+ # Strength reduced version
1499+ self .assertIn ("_CHECK_FUNCTION_VERSION_INLINE" , uops )
1500+ self .assertNotIn ("_CHECK_FUNCTION_VERSION" , uops )
1501+ # Removed guard
1502+ self .assertNotIn ("_CHECK_FUNCTION_EXACT_ARGS" , uops )
1503+
1504+
1505+ def global_identity (x ):
1506+ return x
1507+
14841508
14851509if __name__ == "__main__" :
14861510 unittest .main ()
You can’t perform that action at this time.
0 commit comments