Commit 8b4c0ef
Add new flow graph optimization to fold to constants
Summary:
3.16 added a new flow graph optimization. This catches our compiler up.
PythonLib/cinderx/compiler/flow_graph_optimizer.py
- Generalized fold_constant_intrinsic_list_to_tuple → fold_constant_seq_into_load_const, mirroring upstream: the target may be the LIST_TO_TUPLE intrinsic or a trailing LIST_APPEND/SET_ADD, with sets folding to a frozenset. Behavior for 3.14/3.15 is unchanged (their
only caller still passes the intrinsic).
- Added FlowGraphOptimizer316 with the new LIST_APPEND/SET_ADD handler and the reordered CALL_INTRINSIC_1 handler.
PythonLib/cinderx/compiler/pyassem.py — PyFlowGraph316.flow_graph_optimizer = FlowGraphOptimizer316.
PythonLib/test_cinderx/test_compiler/test_optimizer.py — three version-gated regression tests (big const list iteration, big const set membership, and a negative case ensuring a list that escapes is still built as a list). Two of the three fail without the fix; 3.12
is skipped since it folds big constant sequences in codegen instead.
Reviewed By: yoney
Differential Revision: D116650708
fbshipit-source-id: 6b2626b6aaa5ba002d18ee8c986068d5731f3cb41 parent 5e7c015 commit 8b4c0ef
3 files changed
Lines changed: 134 additions & 17 deletions
File tree
- cinderx/PythonLib
- cinderx/compiler
- test_cinderx/test_compiler
Lines changed: 95 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1048 | 1048 | | |
1049 | 1049 | | |
1050 | 1050 | | |
1051 | | - | |
1052 | | - | |
1053 | | - | |
1054 | | - | |
1055 | | - | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
1056 | 1076 | | |
1057 | 1077 | | |
1058 | 1078 | | |
1059 | 1079 | | |
1060 | 1080 | | |
1061 | 1081 | | |
1062 | 1082 | | |
1063 | | - | |
| 1083 | + | |
1064 | 1084 | | |
1065 | 1085 | | |
1066 | 1086 | | |
1067 | 1087 | | |
1068 | 1088 | | |
1069 | 1089 | | |
1070 | | - | |
1071 | | - | |
1072 | | - | |
1073 | | - | |
1074 | | - | |
1075 | | - | |
1076 | | - | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
1077 | 1097 | | |
1078 | 1098 | | |
1079 | | - | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
1080 | 1103 | | |
1081 | 1104 | | |
1082 | 1105 | | |
1083 | | - | |
| 1106 | + | |
1084 | 1107 | | |
1085 | 1108 | | |
1086 | 1109 | | |
1087 | | - | |
1088 | 1110 | | |
1089 | 1111 | | |
1090 | 1112 | | |
| |||
1101 | 1123 | | |
1102 | 1124 | | |
1103 | 1125 | | |
1104 | | - | |
| 1126 | + | |
1105 | 1127 | | |
1106 | 1128 | | |
1107 | 1129 | | |
| |||
1154 | 1176 | | |
1155 | 1177 | | |
1156 | 1178 | | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
1157 | 1235 | | |
1158 | 1236 | | |
1159 | 1237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
3305 | 3306 | | |
3306 | 3307 | | |
3307 | 3308 | | |
| 3309 | + | |
3308 | 3310 | | |
3309 | 3311 | | |
3310 | 3312 | | |
| |||
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
| |||
483 | 488 | | |
484 | 489 | | |
485 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
486 | 523 | | |
487 | 524 | | |
488 | 525 | | |
| |||
0 commit comments