File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -1083,5 +1083,52 @@ def test_no_unsafe_static_swap(self):
1083
1083
]
1084
1084
self .cfg_optimization_test (insts , expected_insts , consts = list (range (3 )), nlocals = 1 )
1085
1085
1086
+ def test_dead_store_elimination_in_same_lineno (self ):
1087
+ insts = [
1088
+ ('LOAD_CONST' , 0 , 1 ),
1089
+ ('LOAD_CONST' , 1 , 2 ),
1090
+ ('LOAD_CONST' , 2 , 3 ),
1091
+ ('SWAP' , 3 , 4 ),
1092
+ ('STORE_FAST' , 1 , 4 ),
1093
+ ('STORE_FAST' , 1 , 4 ),
1094
+ ('STORE_FAST' , 1 , 4 ),
1095
+ ('RETURN_VALUE' , 5 )
1096
+ ]
1097
+ expected_insts = [
1098
+ ('LOAD_CONST' , 0 , 1 ),
1099
+ ('LOAD_CONST' , 1 , 2 ),
1100
+ ('LOAD_CONST' , 2 , 3 ),
1101
+ ('SWAP' , 3 , 4 ),
1102
+ ('POP_TOP' , 0 , 4 ),
1103
+ ('POP_TOP' , 0 , 4 ),
1104
+ ('STORE_FAST' , 1 , 4 ),
1105
+ ('RETURN_VALUE' , 5 )
1106
+ ]
1107
+ self .cfg_optimization_test (insts , expected_insts , consts = list (range (3 )), nlocals = 1 )
1108
+
1109
+ def test_no_dead_store_elimination_in_different_lineno (self ):
1110
+ insts = [
1111
+ ('LOAD_CONST' , 0 , 1 ),
1112
+ ('LOAD_CONST' , 1 , 2 ),
1113
+ ('LOAD_CONST' , 2 , 3 ),
1114
+ ('SWAP' , 3 , 4 ),
1115
+ ('STORE_FAST' , 1 , 4 ),
1116
+ ('STORE_FAST' , 1 , 5 ),
1117
+ ('STORE_FAST' , 1 , 6 ),
1118
+ ('RETURN_VALUE' , 5 )
1119
+ ]
1120
+ expected_insts = [
1121
+ ('LOAD_CONST' , 0 , 1 ),
1122
+ ('LOAD_CONST' , 1 , 2 ),
1123
+ ('LOAD_CONST' , 2 , 3 ),
1124
+ ('SWAP' , 3 , 4 ),
1125
+ ('STORE_FAST' , 1 , 4 ),
1126
+ ('STORE_FAST' , 1 , 5 ),
1127
+ ('STORE_FAST' , 1 , 6 ),
1128
+ ('RETURN_VALUE' , 5 )
1129
+ ]
1130
+ self .cfg_optimization_test (insts , expected_insts , consts = list (range (3 )), nlocals = 1 )
1131
+
1132
+
1086
1133
if __name__ == "__main__" :
1087
1134
unittest .main ()
You can’t perform that action at this time.
0 commit comments