summaryrefslogtreecommitdiff
path: root/fparser/fpoptimizer.cc
blob: 4eab746805c4ed74cba817a8e74e088d8d86f503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
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
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
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
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
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
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
/***************************************************************************\
|* Function Parser for C++ v4.5.1                                          *|
|*-------------------------------------------------------------------------*|
|* Function optimizer                                                      *|
|*-------------------------------------------------------------------------*|
|* Copyright: Joel Yliluoma                                                *|
|*                                                                         *|
|* This library is distributed under the terms of the                      *|
|* GNU Lesser General Public License version 3.                            *|
|* (See lgpl.txt and gpl.txt for the license text.)                        *|
\***************************************************************************/

/* NOTE:
 This file contains generated code (from the optimizer sources) and is
 not intended to be modified by hand. If you want to modify the optimizer,
 download the development version of the library.
*/

#include "fpconfig.hh"
#ifdef FP_SUPPORT_OPTIMIZER
#include "fparser.hh"
#include "extrasrc/fptypes.hh"
#include "extrasrc/fpaux.hh"
#define l14 {Value_t
#define l04 ),info,
#define iZ3 {data->
#define iY3 ==cNot||
#define iX3 "Found "
#define iW3 info.lQ[b
#define iV3 ;o<<"\n";
#define iU3 )yR 2,cPow
#define iT3 ;}static yU1
#define iS3 (tree)!=
#define iR3 ),Value(
#define iQ3 stackpos
#define iP3 minValue0
#define iO3 "dup(%u) "
#define iN3 =true;iO1
#define iM3 eR{assert
#define iL3 "%d, cost "
#define iK3 "PUSH " iL2
#define iJ3 "immed "<<
#define iI3 mFuncParsers
#define iH3 param.data
#define iG3 stderr
#define iF3 sep2=" "
#define iE3 FPHASH_CONST
#define iD3 cache_needed[
#define iC3 fprintf
#define iB3 "Applying "
#define iA3 FUNCTIONPARSER_INSTANTIATE_OPTIMIZE
#define i93 FUNCTIONPARSER_INSTANTIATE_EMPTY_OPTIMIZE
#define i83 HANDLE_UNARY_CONST_FUNC
#define i73 {if(n11
#define i63 second;
#define i53 within,
#define i43 AddFrom(
#define i33 tH3==
#define i23 c_count
#define i13 MaxOp
#define i03 else nM
#define tZ3 =tZ cL3
#define tY3 .nJ 0));
#define tX3 .nJ 1));
#define tW3 lD m.
#define tV3 ;a<tree.xB
#define tU3 iZ);}if
#define tT3 cS ifp2
#define tS3 sim.xB1
#define tR3 );tO tL1
#define tQ3 ].swap(
#define tP3 codes[b
#define tO3 whydump
#define tN3 for lS1
#define tM3 for(;a<
#define tL3 nparams
#define tK3 281856,
#define tJ3 cTan i7
#define tI3 l2 2,2,
#define tH3 ;if(op
#define tG3 l4 0,1,
#define tF3 0x12 nH
#define tE3 FixIncompleteHashes()
#define tD3 cSinh,
#define tC3 ,cTan nS
#define tB3 ,iX 1,
#define tA3 nS 0,
#define t93 cAbs nS
#define t83 ;case
#define t73 i1 t83
#define t63 Params[
#define t53 Params(
#define t43 &&p nL3
#define t33 fp_pow(
#define t23 false;}
#define t13 lD1 y4.
#define t03 cAbsIf)
#define eZ3 l91++b)
#define eY3 lX1 nC==
#define eX3 ;exponent
#define eW3 =false;
#define eV3 tN cS1);
#define eU3 .empty()
#define eT3 nS3))n92
#define eS3 (opcode==
#define eR3 <data eJ3;++
#define eQ3 l14 nS3(
#define eP3 ByteCodeSynth xF
#define eO3 std xM3<
#define eN3 middle2
#define eM3 std::string
#define eL3 SetOpcode(
#define eK3 ;for iZ1
#define eJ3 .size()
#define eI3 ].second
#define eH3 ].first
#define eG3 return p
#define eF3 TreeCountItem
#define eE3 }return
#define eD3 Ne_Mask
#define eC3 Gt_Mask
#define eB3 Lt_Mask
#define eA3 const eK
#define e93 .n7 synth.
#define e83 range nE3
#define e73 eK3 a=
#define e63 ,eQ,c92
#define e53 eO|lT1)
#define e43 public:
#define e33 Rehash(
#define e23 switch(
#define e13 pclone
#define e03 cOr,l6
#define cZ3 newpow
#define cY3 change
#define cX3 (Value_t
#define cW3 (count
#define cV3 133,2,
#define cU3 ,tree
#define cT3 byteCode
#define cS3 child)
#define cR3 (p1 x41)
#define cQ3 cLog2by
#define cP3 long iD1
#define cO3 factor_t
#define cN3 (p0 yI&&
#define cM3 value1
#define cL3 a));if(!
#define cK3 fp_mod(
#define cJ3 else{if(
#define cI3 )min.set(
#define cH3 xF());nD
#define cG3 max.known
#define cF3 known&&
#define cE3 tX p2;p2
#define cD3 {tree.x4
#define cC3 cAbsNot
#define cB3 ,x53 l8
#define cA3 e23 lY1
#define c93 xW 0)nC
#define c83 IsLogicalValue(xW
#define c73 }switch
#define c63 stackptr
#define c53 cLog);xG
#define c43 l8 0));
#define c33 opcodes
#define c23 did_muli
#define c13 &Value){
#define c03 yD const
#define yZ3 (param.
#define yY3 ){e23
#define yX3 :if(&*lE1){
#define yW3 :{n31 r=
#define yV3 xY3 e23
#define yU3 param=*(
#define yT3 cAbsIf,
#define yS3 cNotNot,
#define yR3 l4 16,1,
#define yQ3 yO3 info
#define yP3 lE1=r.specs;if(r.found){
#define yO3 *x8)[a].
#define yN3 cLess,cH
#define yM3 default_function_handling
#define yL3 l4 20,1,
#define yK3 l4 4,1,
#define yJ3 450998,
#define yI3 cExp2 nS
#define yH3 lJ 2},0,
#define yG3 )lS 3*3*2*2
#define yF3 default:
#define yE3 range<nV
#define yD3 range xF
#define yC3 Ge0Lt1
#define yB3 Gt0Le1
#define yA3 cAdd lV2
#define y93 if(op1==
#define y83 iterator
#define y73 begin();
#define y63 TreeSet
#define y53 parent
#define y43 insert(i
#define y33 newrel
#define y23 y03 xX3 xO2
#define y13 y03 iF2;if(
#define y03 ))return
#define xZ3 ;if(half
#define xY3 break;}
#define xX3 IsNever
#define xW3 e62 eO1
#define xV3 synth.xH
#define xU3 b_needed
#define xT3 cachepos
#define xS3 ,lE1,info
#define xR3 half=
#define xQ3 131,4,1,
#define xP3 131,8,1,
#define xO3 ,iM,1,lC1+1);
#define xN3 4,1,2,1,
#define xM3 ::vector
#define xL3 1 y5 n41
#define xK3 FindPos(
#define xJ3 src_pos
#define xI3 xM1 xQ+
#define xH3 reserve(
#define xG3 treeptr
#define xF3 .resize(
#define xE3 tO1 void
#define xD3 ImmedTag
#define xC3 a,const
#define xB3 RefCount
#define xA3 Birth();
#define x93 typename
#define x83 unsigned
#define x73 template
#define x63 7168,
#define x53 leaf1
#define x43 cost_t
#define x33 fpdata
#define x23 middle
#define x13 sqrt_cost
#define x03 const int
#define nZ3 mul_count
#define nY3 );nZ l5::
#define nX3 e62 2)));
#define nW3 maxValue1
#define nV3 minValue1
#define nU3 maxValue0
#define nT3 ValueType
#define nS3 result
#define nR3 nS3;}case
#define nQ3 nS3.tL
#define nP3 ::res,b8<
#define nO3 eG3 yM
#define nN3 .what nS1
#define nM3 e62 1),e62 1));
#define nL3 .max.val
#define nK3 nS3 yM2
#define nJ3 nS3 e61
#define nI3 nS3 yI
#define nH3 nS3 nL3
#define nG3 nS3 tG1
#define nF3 nS3 yM
#define nE3 xF nS3
#define nD3 tO n3 0),
#define nC3 i8);nD lC
#define nB3 abs_mul
#define nA3 xM3<x83>&e71
#define n93 l8 a));
#define n83 pos_set
#define n73 goto e1
#define n63 p1.lT2 p1
#define n53 [funcno].
#define n43 eN1[++IP]
#define n33 sim.x2 1,
#define n23 {sim.Eat(
#define n13 eN1[IP]==
#define n03 subtree
#define lZ3 invtree
#define lY3 MakeHash(
#define lX3 parampair
#define lW3 rulenumit
#define lV3 cAnd l3
#define lU3 ,cMul l3
#define lT3 cAnd,l6
#define lS3 x9 lT 2,
#define lR3 },{{1,
#define lQ3 cEqual,
#define lP3 lQ3 lA
#define lO3 t01},{{3,
#define lN3 MakeEqual
#define lM3 nC1,l5::
#define lL3 nC1,{l5::
#define lK3 newbase
#define lJ3 fp_equal(
#define lI3 branch1op
#define lH3 branch2op
#define lG3 if(lJ3
#define lF3 l8 a)xI
#define lE3 overlap
#define lD3 truth_b
#define lC3 truth_a
#define lB3 found_dup
#define lA3 nQ r;r iH
#define l93 void set(
#define l83 {tP1 lE
#define l73 rangeutil
#define l63 Plan_Has(
#define l53 StackMax)
#define l43 i1 true;}
#define l33 namespace
#define l23 (cond yX
#define l13 inverted
#define l03 xX3:
#define iZ2 iftree
#define iY2 depcodes
#define iX2 explicit
#define iW2 cCosh nS
#define iV2 t01 nH
#define iU2 VarBegin
#define iT2 t63 a]
#define iS2 iR2 size()
#define iR2 Params.
#define iQ2 ].data);
#define iP2 i8)));nZ
#define iO2 yQ1.SubTrees
#define iN2 yQ1.Others
#define iM2 );synth
#define iL2 ;DumpTree(
#define iK2 ;Value_t
#define iJ2 begin(),
#define iI2 cond_add
#define iH2 cond_mul
#define iG2 cond_and
#define iF2 IsAlways
#define iE2 func lQ1
#define iD2 bool eM1
#define iC2 Forget()
#define iB2 .second);
#define iA2 Optimize()
#define i92 costree
#define i82 sintree
#define i72 leaf_count
#define i62 &&cond eD)
#define i52 .tT1 n]
#define i42 =GetParam(
#define i32 sub_params
#define i22 nC==cLog2&&
#define i12 nC==cPow&&
#define i02 printf(
#define tZ2 cbrt_count
#define tY2 sqrt_count
#define tX2 cPow i7
#define tW2 ,cPow,
#define tV2 ,cGreater
#define tU2 exponent);
#define tT2 Finite
#define tS2 min.n3 0),
#define tR2 p1 cS ifp1
#define tQ2 yR 2,cAdd)
#define tP2 pcall_tree
#define tO2 after_powi
#define tN2 GetHash().
#define tM2 yP t23
#define tL2 params)
#define tK2 grammar
#define tJ2 cEqual t11
#define tI2 cLog nS
#define tH2 cNeg,lT 1,
#define tG2 ),0},{
#define tF2 std::move(
#define tE2 iH cond nC
#define tD2 tree iH
#define tC2 ){eL3
#define tB2 tree))cJ
#define tA2 );t0=!t0;}
#define t92 tmp c91 tree
#define t82 nQ tmp;tmp iH
#define t72 tree nC
#define t62 MakeNEqual
#define t52 )?0:1))l7
#define t42 isInteger(
#define t32 Comparison
#define t22 needs_flip
#define t12 (half&63)-1;
#define t02 value]
#define eZ2 lT1 opcode
#define eY2 )lS 3*3*3*2
#define eX2 cS tree);
#define eW2 mul_item
#define eV2 innersub
#define eU2 cbrt_cost
#define eT2 best_cost
#define eS2 condition
#define eR2 nominator
#define eQ2 per_item
#define eP2 item_type
#define eO2 first2
#define eN2 l4 18,1,
#define eM2 cIf,iX 3,
#define eL2 lJ 1},0,
#define eK2 tJ 1},0,
#define eJ2 Decision
#define eI2 not_tree
#define eH2 (mulgroup
#define eG2 (lR));nD lC
#define eF2 Become(xW
#define eE2 group_by
#define eD2 exponent=
#define eC2 ->second
#define eB2 targetpos
#define eA2 ParamSpec
#define e92 rhs.hash2;}
#define e82 rhs.hash1
#define e72 struct
#define e62 Value_t(
#define e52 .n_int_sqrt
#define e42 const std::eP
#define e32 const char*
#define e22 nT 409641,
#define e12 ,xF1);lC
#define e02 );xY3
#define cZ2 if(t72==
#define cY2 eO3 bool>
#define cX2 ,(long double)
#define cW2 ContainsOtherCandidates
#define cV2 std::cout
#define cU2 source_tree
#define cT2 GetParam eS
#define cS2 <tP,x43>
#define cR2 p1_evenness
#define cQ2 isNegative(
#define cP2 neg_set
#define cO2 }else{x8=new
#define cN2 );}void
#define cM2 cNop,cNop}}
#define cL2 cTanh,cNop,
#define cK2 NewHash
#define cJ2 >e72 cB<
#define cI2 matches
#define cH2 {cV2<<
#define cG2 iS1 void*)&
#define cF2 cGreater,cH
#define cE2 cSin i7
#define cD2 cCos nS
#define cC2 ,t21 0x1 nH
#define cB2 +=1 i1 n91;
#define cA2 negated
#define c92 synth);
#define c82 Specializer
#define c72 ifdata.ofs
#define c62 (IfData&ifdata
#define c52 .push_back(
#define c42 ;}data;data.
#define c32 );sim.x2 2,
#define c22 nP)l14 tmp=
#define c12 (*x8)[0].info
#define c02 CodeTree
#define yZ2 c02 xF
#define yY2 coshtree
#define yX2 sinhtree
#define yW2 best_score
#define yV2 mulvalue
#define yU2 pow_item
#define yT2 subgroup
#define yS2 PowiResult
#define yR2 .match_tree
#define yQ2 )l43
#define yP2 0));yD3
#define yO2 maxValue
#define yN2 minValue
#define yM2 yI eW3 if(
#define yL2 fp_min(yL,
#define yK2 div_tree
#define yJ2 pow_tree
#define yI2 preserve
#define yH2 ,cCos i7
#define yG2 (rule cU3,info
#define yF2 e62 0.5)
#define yE2 PullResult()
#define yD2 dup_or_fetch
#define yC2 e33 false
#define yB2 test_order
#define yA2 lX3,
#define y92 .param_count
#define y82 shift(index)
#define y72 rulenumber
#define y62 cTanh nS
#define y52 cSinh nS
#define y42 cInv,lT 1,
#define y32 constraints=
#define y22 factor_immed
#define y12 changes
#define y02 n81 cS y4 l8
#define xZ2 cS leaf2 l8
#define xY2 cS x53 l8
#define xX2 cS cond l8
#define xW2 exp_diff
#define xV2 ExponentInfo
#define xU2 lower_bound(
#define xT2 factor
#define xS2 is_logical
#define xR2 newrel_and
#define xQ2 tH[c eE
#define xP2 ;iM.Remember(
#define xO2 i1 Unknown;}
#define xN2 res_stackpos
#define xM2 half_pos
#define xL2 >>1)):(
#define xK2 CodeTreeData
#define xJ2 multiply(
#define xI2 tO known)
#define xH2 var_trees
#define xG2 erase(cs_it);
#define xF2 parent_opcode
#define xE2 log2_exponent
#define xD2 yB swap(tmp);
#define xC2 Value(Value::
#define xB2 dup_fetch_pos
#define xA2 a;if(eK1){x8=
#define x92 {cZ start_at;
#define x82 xX3 cQ lC
#define x72 cSin nS
#define x62 Value_EvenInt
#define x52 )){data xC
#define x42 MakeFalse,{l5
#define x32 if(list.first
#define x22 AddCollection
#define x12 ConditionType
#define x02 DUP_ONE(apos)
#define nZ2 SpecialOpcode
#define nY2 =i eC2.
#define nX2 IsDefined()
#define nW2 fp_max(yL);
#define nV2 (tree,cV2
#define nU2 e62-1)
#define nT2 assimilated
#define nS2 denominator
#define nR2 fraction
#define nQ2 l2 18,2,
#define nP2 .GetDepth()
#define nO2 iH t72)
#define nN2 xI leaf2 l8
#define nM2 DUP_BOTH();
#define nL2 x73 lL
#define nK2 -1-offset].
#define nJ2 tree.GetHash()
#define nI2 TreeCounts
#define nH2 ,e62 1))){
#define nG2 bool t0 eW3
#define nF2 found_log2
#define nE2 div_params
#define nD2 immed_sum
#define nC2 :sim.Eat(1,
#define nB2 OPCODE(opcode)
#define nA2 ;sim.Push(
#define n92 break;nS3*=
#define n82 FactorStack xF
#define n72 iF2 cQ lC
#define n62 cLessOrEq,
#define n52 282870 nT
#define n42 cNotNot nS
#define n32 cNot nS
#define n22 replacing_slot
#define n12 RefParams
#define n02 if_always[
#define lZ2 WhatDoWhenCase
#define lY2 exponent_immed
#define lX2 new_base_immed
#define lW2 base_immed
#define lV2 ||op1==
#define lU2 remaining
#define lT2 Rehash t8
#define lS2 data[a eI3
#define lR2 lT2 r);}
#define lQ2 if(newrel_or==
#define lP2 .UseGetNeeded(
#define lO2 e7 2,131,
#define lN2 Immed eJ3);
#define lM2 OptimizedUsing
#define lL2 Var_or_Funcno
#define lK2 lL2;
#define lJ2 GetParams(
#define lI2 crc32_t
#define lH2 signed_chain
#define lG2 MinusInf
#define lF2 synth.Find(
#define lE2 );cV2<<
#define lD2 return true;
#define lC2 n_immeds
#define lB2 stack eJ3
#define lA2 FindClone(xM
#define l92 GetOpcode())
#define l82 needs_rehash
#define l72 AnyWhere_Rec
#define l62 minimum_need
#define l52 ~x83(0)
#define l42 41,42,43,44,
#define l32 p1_logical_b
#define l22 p0_logical_b
#define l12 p1_logical_a
#define l02 p0_logical_a
#define iZ1 (size_t
#define iY1 )e73
#define iX1 TopLevel)
#define iW1 .e33)
#define iV1 {pow.CopyOnWrite
#define iU1 nB OPCODE
#define iT1 const yZ2
#define iS1 (const
#define iR1 iS1 yZ2&
#define iQ1 ,PowiCache&iM,
#define iP1 else if(
#define iO1 iP1!nS3
#define iN1 synth.DoDup(
#define iM1 cache_needed
#define iL1 e7 2,1,e7 2,
#define iK1 [c72+
#define iJ1 treelist
#define iI1 IsDescendantOf(
#define iH1 has_bad_balance
#define iG1 )tN mulgroup)
#define iF1 .SetParamsMove(
#define iE1 cO3 xT2
#define iD1 double)exponent
#define iC1 {if(GetOpcode()
#define iB1 cV2<<std::y11
#define iA1 cV2<<"POP "
#define i91 DelParam(
#define i81 set(fp_ceil);tK
#define i71 fp_abs(max.val))
#define i61 fp_abs(min.val)
#define i51 cNEqual
#define i41 },0,0x0},{{
#define i31 tJ 2 i41
#define i21 Oneness_NotOne|
#define i11 Value_IsInteger
#define i01 Constness_Const
#define tZ1 DumpHashesFrom(
#define tY1 reltype
#define tX1 const Value_t&i)
#define tW1 const c02&
#define tV1 const Value_t&v
#define tU1 SequenceOpcodes
#define tT1 sep_list[
#define tS1 ;else_tree
#define tR1 goto fail;}
#define tQ1 l1 0x4 nH
#define tP1 x73<
#define tO1 n12);
#define tN1 ){case iF2:
#define tM1 grammar_rules[*r]
#define tL1 x73 set_if<
#define tK1 x73 lX
#define tJ1 TreeCountType xF
#define tI1 GetParamCount(nX
#define tH1 >(e62 1),
#define tG1 nL3)
#define tF1 )lX3.second
#define tE1 e62 0.0)){nU
#define tD1 .IsImmed()
#define tC1 a)tD1)
#define tB1 nB2);
#define tA1 stack[lB2-
#define t91 stack c52
#define t81 )eX3 iW1;
#define t71 synth.PushImmed(
#define t61 MaxChildDepth
#define t51 repl_param_list,
#define t41 const Rule&rule,
#define t31 std::pair<It,It>
#define t21 cPow,lA
#define t11 ,l0 2,
#define t01 ,l1 0x12
#define eZ1 Sign_Negative
#define eY1 Value_Logical
#define eX1 yZ2&b
#define eW1 new_factor_immed
#define eV1 occurance_pos
#define eU1 exponent_hash
#define eT1 exponent_list
#define eS1 CollectionSet xF
#define eR1 CollectMulGroup(
#define eQ1 source_set
#define eP1 exponent,y63
#define eO1 *const func)(
#define eN1 ByteCode
#define eM1 operator
#define eL1 FindAndDup(tree);
#define eK1 &*start_at
#define eJ1 <<nJ2.
#define eI1 xW 1)tD1&&
#define eH1 retry_anyparams_3
#define eG1 retry_anyparams_2
#define eF1 e6(),eO3
#define eE1 needlist_cached_t
#define eD1 yH3 0x4 lR3
#define eC1 eL2 0x4 lR3
#define eB1 ),lM2(
#define eA1 CodeTreeImmed xF(
#define e91 GetParamCount()==
#define e81 .back().thenbranch
#define e71 eN1,size_t&IP,size_t limit,size_t y2
#define e61 .cG3
#define e51 (lR,xW i8));nD
#define e41 ;flipped=!flipped;}
#define e31 ,l1 0x0},{{3,
#define e21 }xY3 case
#define e11 for iZ1 b=0;b<
#define e01 by_float_exponent
#define cZ1 lJ3 exponent
#define cY1 new_exp
#define cX1 end()&&i->first==
#define cW1 return BecomeZero;
#define cV1 =comp.AddItem(atree
#define cU1 return BecomeOne;
#define cT1 if(lQ eJ3<=n1)
#define cS1 addgroup
#define cR1 found_log2by
#define cQ1 nC==cC3)
#define cP1 ParsePowiMuli(
#define cO1 lL2)
#define cN1 eL 529654 nT
#define cM1 branch1_backup
#define cL1 branch2_backup
#define cK1 exponent_map
#define cJ1 plain_set
#define cI1 rangehalf
#define cH1 LightWeight(
#define cG1 xV3 1
#define cF1 divgroup
#define cE1 ,iM e63
#define cD1 if(value
#define cC1 tK1 c0
#define cB1 tK1 static
#define cA1 mulgroup.
#define c91 .AddParamMove(
#define c81 yB AddParamMove(
#define c71 ;n81 cY op1 yB DelParams
#define c61 should_regenerate=true;
#define c51 should_regenerate,
#define c41 Collection
#define c31 RelationshipResult
#define c21 Subdivide_Combine(
#define c11 long value
#define c01 )const yP
#define yZ1 rhs c01 hash1
#define yY1 for iZ1 a xY
#define yX1 best_sep_factor
#define yW1 SynthesizeParam
#define yV1 needlist_cached
#define yU1 inline x83
#define yT1 opcode,bool pad
#define yS1 changed=true;
#define yR1 );xM iF1
#define yQ1 NeedList
#define yP1 tK1 bool
#define yO1 ;tK1
#define yN1 i91 a);}
#define yM1 MakesInteger(
#define yL1 const Value_t&value
#define yK1 best_sep_cost
#define yJ1 MultiplicationRange
#define yI1 .min.set(fp_floor);
#define yH1 pihalf_limits
#define yG1 yR 2,cMul);lC
#define yF1 n_stacked
#define yE1 cK2.hash1
#define yD1 AnyParams_Rec
#define yC1 ;synth.StackTopIs(
#define yB1 synth.AddOperation(
#define yA1 continue;
#define y91 Become(value l8 0))
#define y81 }inline
#define y71 PositionalParams,0}
#define y61 always_sincostan
#define y51 Recheck_RefCount_Div
#define y41 Recheck_RefCount_Mul
#define y31 MultiplyAndMakeLong(
#define y21 covers_plus1
#define y11 endl;DumpHashes(
#define y01 if(synth.FindAndDup(
#define xZ1 grammar_func
#define xY1 tree tD1 cQ
#define xX1 cOr l3 16,1,
#define xW1 252421 nT 24830,
#define xV1 l2 0,2,165888 nT
#define xU1 Modulo_Radians},
#define xT1 yB SetParam(
#define xS1 PositionType
#define xR1 CollectionResult
#define xQ1 const_offset
#define xP1 inline TriTruthValue
#define xO1 stacktop_desired
#define xN1 iU3);lC
#define xM1 SetStackTop(
#define xL1 tK1 void
#define xK1 FPoptimizer_ByteCode
#define xJ1 1)?(poly^(
#define xI1 eP3&synth)
#define xH1 e62 0)
#define xG1 xH1)
#define xF1 cond_type
#define xE1 fphash_value_t
#define xD1 Recheck_RefCount_RDiv
#define xC1 cMul);tmp tY3 tmp.
#define xB1 SwapLastTwoInStack();
#define xA1 SetParams(lJ2)
#define x91 fPExponentIsTooLarge(
#define x81 CollectMulGroup_Item(
#define x71 pair<Value_t,y63>
#define x61 (x53 l8 1)nN2
#define x51 for iZ1 a=0;a<yC++a)
#define x41 .GetImmed()
#define x31 {int mStackPtr=0;
#define x21 nL xM1 xQ-1);
#define x11 covers_full_cycle
#define x01 AssembleSequence(
#define nZ1 inverse_nominator
#define nY1 252180 nT 281854,
#define nX1 <<std::dec<<")";}
#define nW1 {DataP slot_holder(y1[
#define nV1 },{l5::MakeNotP1,l5::
#define nU1 },{l5::MakeNotP0,l5::
#define nT1 },{l5::MakeNotNotP1,l5::
#define nS1 !=xJ)if(TestCase(
#define nR1 AddFunctionOpcode
#define nQ1 public e6,public eO3
#define nP1 yZ2&tree,
#define nO1 std::pair<T1,T2>&
#define nN1 tP1 x93
#define nM1 has_good_balance_found
#define nL1 n_occurrences
#define nK1 found_log2_on_exponent
#define nJ1 covers_minus1
#define nI1 needs_resynth
#define nH1 immed_product
#define nG1 l33 FPoptimizer_Optimize
#define nF1 (ParamSpec_Extract xF(
#define nE1 yV3 bitmask&
#define nD1 Sign_Positive
#define nC1 ::MakeTrue
#define nB1 SetParamMove(
#define nA1 CodeTreeImmed(e62
#define n91 Suboptimal
#define n81 changed_if
#define n71 n_as_tanh_param
#define n61 opposite=
#define n51 xE1(
#define n41 eN1 eJ3
#define n31 MatchResultType
#define n21 yP yZ2(
#define n11 needs_sincos
#define n01 resulting_exponent
#define lZ1 Unknown:yF3;}
#define lY1 GetLogicalValue(xW
#define lX1 GetParam(a)
#define lW1 cMul l3 0,1,
#define lV1 IsImmed())l14
#define lU1 void FunctionParserBase
#define lT1 (x83
#define lS1 lT1 a=0;a<xT;++a)
#define lR1 o<<"("<<std::hex<<data.
#define lQ1 (val);else*this=model;}
#define lP1 IfBalanceGood(
#define lO1 n_as_tan_param
#define lN1 changed_exponent
#define lM1 inverse_denominator
#define lL1 ;cK2.hash2+=
#define lK1 retry_positionalparams_2
#define lJ1 x83 index
#define lI1 situation_flags&
#define lH1 518 nT 400412,
#define lG1 data.subfunc_opcode
#define lF1 },{l5::MakeNotNotP0,l5::
#define lE1 (yO3 start_at
#define lD1 CopyOnWrite();
#define lC1 recursioncount
#define lB1 PlanNtimesCache(
#define lA1 FPoptimizer_Grammar
#define l91 GetParamCount();
#define l81 GetPositivityInfo iS3
#define l71 ParamSpec_SubFunctionData
#define l61 t43<e62
#define l51 (tree.GetParamCount()
#define l41 iZ1 a=yC a-->0;)
#define l31 PositionalParams_Rec
#define l21 DumpTreeWithIndent(*this);
#define l11 e23 type){case cond_or:
#define l01 tP1 x83 Compare>
#define iZ tree.i91 a
#define iY .l91 a-->0;)if(
#define iX lA 0x4},{{
#define iW lJ 2 i41 1,
#define iV edited_powgroup
#define iU has_unknown_max
#define iT has_unknown_min
#define iS static const yD3
#define iR if(keep_powi
#define iQ synthed_tree
#define iP 7168 nT 401798,
#define iO SelectedParams,0 i41
#define iN collections
#define iM cache
#define iL ,cIf,l0 3,
#define iK ,eN1,IP,limit,y2,stack);
#define iJ by_exponent
#define iI );p2.lT2 p2 yB eL3 iZ2 nC);cJ}
#define iH .eL3
#define iG mulgroup;mulgroup iH
#define iF (p0 e61&&p0 nL3 i2
#define iE cN3 p0 yM>=e62 0.0))
#define iD goto ReplaceTreeWithOne t83
#define iC !=xJ)return n02
#define iB e01.data
#define iA iX2 xK2(
#define i9 needs_sinhcosh
#define i8 1)x41
#define i7 ,l4 2,1,
#define i6 cAdd l3 0,
#define i5 tG2 e62
#define i4 tK1 n9
#define i3 MakeFalse,l5::
#define i2 <=fp_const_negativezero xF())
#define i1 ;return
#define i0 )i1 lH
#define tZ CalculateResultBoundaries(xW
#define tY p0=CalculateResultBoundaries(
#define tX ;yZ2
#define tW ,2,1 iM2.xR if(found[data.
#define tV 408964 nT 24963,
#define tU 528503 nT 24713,
#define tT matched_params
#define tS [n1 eH3=true;lQ[n1 eI3
#define tR lA1::Grammar*
#define tQ AddOperation(cInv,1,1 iM2.xR}
#define tP int_exponent_t
#define tO m.max.
#define tN ;AddParamMove(
#define tM nM nU2,e62 1));
#define tL cG3 eW3
#define tK return m;}case
#define tJ x9 AnyParams,
#define tI powgroup l8
#define tH relationships
#define tG ]!=~size_t(0)){synth.yT
#define tF }},{ProduceNewTree,2,1,
#define tE nA1(
#define tD has_mulgroups_remaining
#define tC MatchInfo xF&
#define tB e33);i32 c52
#define tA best_factor
#define t9 RootPowerTable xF::RootPowers[
#define t8 (c81
#define t7 :goto ReplaceTreeWithZero t83
#define t6 MatchPositionSpec_AnyParams xF
#define t5 l33 FPoptimizer_CodeTree
#define t4 n_as_sinh_param
#define t3 n_as_cosh_param
#define t2 ();pow iH cLog yB eL3 cMul
#define t1 0,tU2 i91 1);
#define t0 is_signed
#define eZ result_positivity
#define eY biggest_minimum
#define eX const l71
#define eW 122999 nT 139399,
#define eV 142455 nT 141449,
#define eU cond_tree
#define eT then_tree
#define eS (a);bool needs_cow=GetRefCount()>1;
#define eR yZ2&tree)
#define eQ sequencing
#define eP string FP_GetOpcodeName(
#define eO );eN1 c52 0x80000000u
#define eN {if(needs_cow){lD1 goto
#define eM (lJ2));cA1 e33);
#define eL ,nQ2
#define eK eO3 yZ2>
#define eJ if_stack
#define eI n_as_sin_param
#define eH n_as_cos_param
#define eG PowiResolver::
#define eF cIf,tG3
#define eE ].relationship
#define eD .BalanceGood
#define eC AddParamMove(yT2
#define eB valueType
#define eA back().endif_location
#define e9 xE1 key
#define e8 AddParamMove(mul);
#define e7 130,1,
#define e6 MatchPositionSpecBase
#define e5 iX2 c02(
#define e4 smallest_maximum
#define e3 ]!=~size_t(0)&&found[data.
#define e2 }PACKED_GRAMMAR_ATTRIBUTE;
#define e1 ReplaceTreeWithParam0;
#define e0 factor_needs_rehashing
#define cZ MatchPositionSpecBaseP
#define cY .e33 yB eL3
#define cX x93 tJ1::y83
#define cW ParamSpec_Extract xF(nN.param_list,
#define cV }x32 x41==e62
#define cU 243,244,245,246,249,250,251,253,255,256,257,258,259}};}
#define cT ];};extern"C"{
#define cS .AddParam(
#define cR iL2 tree lE2"\n";
#define cQ )return false;
#define cP 79,122,123,160,161,163,164,165,166,167,168,169,178,179,180,200,204,212,216,224,236,237,239,240,
#define cO 27,28,29,30,31,32,33,35,36,
#define cN const ParamSpec_SubFunction
#define cM const ParamSpec_ParamHolder
#define cL otherhalf
#define cK :{AdoptChildrenWithSameOpcode(tree);
#define cJ goto redo;
#define cI StackState
#define cH l2 16,2,
#define cG const SequenceOpCode xF
#define cF MatchPositionSpec_PositionalParams xF
#define cE const nP1 std::ostream&o
#define cD e62 1.5)*fp_const_pi xF()
#define cC CalculatePowiFactorCost(
#define cB ImmedHashGenerator
#define cA paramholder_matches
#define c9 ::map<fphash_t,std::set<eM3> >
#define c8 ComparisonSetBase::
#define c7 AddParamMove(comp.cJ1[a].value);
#define c6 T1,x93 T2>inline iD2()(
#define c5 has_nonlogical_values
#define c4 from_logical_context)
#define c3 AnyParams,0}},{ProduceNewTree,
#define c2 for iZ1 a=xV.l91 a-->0;)
#define c1 POWI_CACHE_SIZE
#define c0 static inline yZ2
#define yZ ++IP;yA1}if(n13 c33.
#define yY },{l5::xJ,l5::Never},{l5::xJ,l5::Never}}
#define yX .FoundChild
#define yW BalanceResultType
#define yV {yZ2 tmp;tmp iH
#define yU yB1 GetOpcode(),
#define yT DoDup(found[data.
#define yS xB3(0),Opcode(
#define yR ;sim.Eat(
#define yQ );void nR1 eZ2,c82<
#define yP {return
#define yO const yP data->
#define yN +=fp_const_twopi xF();
#define yM .min.val
#define yL fp_sin(min),fp_sin(max))
#define yK fp_const_twopi xF());if(
#define yJ {yZ2 tmp,tmp2;tmp2 iH
#define yI .min.known
#define yH for iZ1 a=0;a<l91++a){if(
#define yG MatchPositionSpec_AnyWhere
#define yF if yZ3 data.match_type==
#define yE void OutFloatHex(std::ostream&o,
#define yD {static void lY3 nB fphash_t&cK2,
#define yC tree.l91
#define yB );tree.
#define yA AddParam(CodeTreeImmed(
#define y9 cGreaterOrEq,
#define y8 ,x93 yZ2::
#define y7 xF model=cI1 xF()){if(known
#define y6 AssembleSequence_Subdivide(
#define y5 ]=0x80000000u|x83(
#define y4 branch2
#define y3 x83 c;x83 short l[
#define y2 factor_stack_base
#define y1 data->Params
#define y0 (lW3 r=range.first;r!=range.i63++r){
#define xZ {nI2.erase(i);yA1}
#define xY =0;a<y53.l91++a)if(
#define xX ,t21 0x4 nH
#define xW tree l8
#define xV branch1
#define xU ,nU2))eN
#define xT nN y92
#define xS =fp_cosh(m yM);tO val=fp_cosh(tO val);
#define xR StackTopIs(*this)i1;}
#define xQ StackTop
#define xP FPOPT_autoptr
#define xO +=nS3 i1 nS3;}tK1 inline Value_t
#define xN int_exponent
#define xM newnode
#define xL lJ 1 i41
#define xK has_highlevel_opcodes
#define xJ Unchanged
#define xI .IsIdenticalTo(
#define xH GetStackTop()-
#define xG sim.AddConst(
#define xF <Value_t>
#define xE cE=cV2
#define xD best_selected_sep
#define xC ->Recalculate_Hash_NoRecursion();}
#define xB l91++a)if(ApplyGrammar(tK2,xW a),
#define xA lU3 2,1,
#define x9 ,cAdd,
#define x8 position
#define x7 x51{yD3
#define x6 ;tmp2 tY3 tmp iH cInv);tmp c91 tmp2)i1
#define x5 eO3 c02>
#define x4 SetParam(0,iZ2 l8 0))tX p1;p1 iH
#define x3 TestImmedConstraints yZ3 constraints cU3)cQ
#define x2 SwapLastTwoInStack()yR
#define x1 n23 1,cInv e02 xG-1 xN1
#define x0 paramholder_index
#define nZ lD2 case
#define nY occurance_counts
#define nX );a-->0;){iT1&powgroup=lX1;if(powgroup
#define nW )){tree.tE3;}
#define nV Value_t>p=tZ a));if(p.
#define nU tree.ReplaceWithImmed(
#define nT ,{2,
#define nS ,l0 1,
#define nR ,cAdd l3 2,1,
#define nQ ){yZ2
#define nP if(xW 0)tD1
#define nO const FPoptimizer_CodeTree::yZ2&tree
#define nN model_tree
#define nM return yD3(
#define nL ){using l33 FUNCTIONPARSERTYPES;
#define nK eK&n12
#define nJ AddParam(xW
#define nI ConstantFolding_LogicCommon(tree,c8
#define nH },{{2,
#define nG nN1 Ref>inline void xP<Ref>::
#define nF AnyParams,1 i41
#define nE ):data(new xK2 xF(
#define nD goto do_return;}
#define nC .GetOpcode()
#define nB FUNCTIONPARSERTYPES::
#define nA b;}};tP1>e72 Comp<nB
#define n9 xK2 xF::xK2(
#define n8 lL2(),t53),Hash(),Depth(1 eB1 0){}
#define n7 SynthesizeByteCode(c92
#define n6 while(ApplyGrammar(cG2
#define n5 GetIntegerInfo(xW 0))==iF2)n73
#define n4 ;tree c91 n81 yQ2
#define n3 tL1 cGreater>(e62
#define n2 DumpParams xF yZ3 data.param_list,iH3 y92,o);
#define n1 restholder_index
#define n0 yZ2 exponent eX3 iH cMul)eX3 cS
#define lZ lR);if(fp_nequal(tmp,xG1){nU e62 1)/tmp);nD}lC
#define lY :if(ParamComparer xF()(t63 1],t63 0])){std::swap(t63 0],t63 1]);Opcode=
#define lX <x93 Value_t>
#define lW xF tmp;tmp iH cPow);tmp tY3 tmp.yA e62
#define lV i01,0x0},
#define lU AddParamMove(pow l8 1));pow.i91 1);pow.e33 yB nB1 0,pow);goto NowWeAreMulGroup;}
#define lT GroupFunction,0},lV{{
#define lS ,e62 1)/e62
#define lR xW 0)x41
#define lQ restholder_matches
#define lP yE1|=key;xE1 crc=(key>>10)|(key<<(64-10))lL1((~n51 crc))*3)^1234567;}};
#define lO n81;n81 nO2;n81 c91 xW 0));n81 cS xV l8
#define lN tK1 yZ2::c02(
#define lM tree.SetParam(0,xW 0)l8 0)xT1 1,CodeTreeImmed(
#define lL lX void eP3::nR1 eZ2,c82<
#define lK cMul,lT 2,
#define lJ cMul,AnyParams,
#define lI (xW 0)tD1&&xW 1)tD1){nU
#define lH CalculateResultBoundaries(tmp);}case
#define lG :cY3=comp.AddRelationship(atree l8 0),atree l8 1),c8
#define lF cPow,l0 2
#define lE x93 Value_t>inline iD2()iS1 Value_t&xC3 Value_t&b)yP a
#define lD {yD3 m=tZ 0));
#define lC break t83
#define lB xL1 yZ2::
#define lA y71,0,
#define l9 l1 0x0 nH
#define l8 .GetParam(
#define l7 tX n81;n81 nO2;n81 iF1 tree.lJ2));n81 cY
#define l6 SelectedParams,0},0,0x0 nH
#define l5 RangeComparisonData
#define l4 y71},{ProduceNewTree,
#define l3 ,AnyParams,0}},{ReplaceParams,
#define l2 y71},{ReplaceParams,
#define l1 cMul,SelectedParams,0},0,
#define l0 lA 0x0},{{
#ifdef _MSC_VER
typedef
x83
int
lI2;
#else
#include <stdint.h>
typedef
uint_least32_t
lI2;
#endif
l33
crc32{enum{startvalue=0xFFFFFFFFUL,poly=0xEDB88320UL}
;tP1
lI2
crc>e72
b8{enum{b1=(crc&xJ1
crc
xL2
crc>>1),b2=(b1&xJ1
b1
xL2
b1>>1),b3=(b2&xJ1
b2
xL2
b2>>1),b4=(b3&xJ1
b3
xL2
b3>>1),b5=(b4&xJ1
b4
xL2
b4>>1),b6=(b5&xJ1
b5
xL2
b5>>1),b7=(b6&xJ1
b6
xL2
b6>>1),res=(b7&xJ1
b7
xL2
b7>>1)}
;}
;inline
lI2
update(lI2
crc,x83
b){
#define B4(n) b8<n>nP3 n+1>nP3 n+2>nP3 n+3>::res
#define R(n) B4(n),B4(n+4),B4(n+8),B4(n+12)
static
const
lI2
table[256]={R(0x00),R(0x10),R(0x20),R(0x30),R(0x40),R(0x50),R(0x60),R(0x70),R(0x80),R(0x90),R(0xA0),R(0xB0),R(0xC0),R(0xD0),R(0xE0),R(0xF0)}
;
#undef R
#undef B4
return((crc>>8))^table[(crc^b)&0xFF];y81
lI2
calc_upd(lI2
c,const
x83
char*buf,size_t
size){lI2
value=c
eK3
p=0;p<size;++p)value=update(value,buf[p])i1
value;y81
lI2
calc
iS1
x83
char*buf,size_t
size)yP
calc_upd(startvalue,buf,size);}
}
#ifndef FPOptimizerAutoPtrHH
#define FPOptimizerAutoPtrHH
nN1
Ref>class
xP{e43
xP():p(0){}
xP(Ref*b):p(b){xA3}
xP
iS1
xP&b):p(b.p){xA3
y81
Ref&eM1*(c01*p;y81
Ref*eM1->(c01
p;}
xP&eM1=(Ref*b){Set(b)i1*this;}
xP&eM1=iS1
xP&b){Set(b.p)i1*this;}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
xP(xP&&b):p(b.p){b.p=0;}
xP&eM1=(xP&&b){if(p!=b.p){iC2;p=b.p;b.p=0;eE3*this;}
#endif
~xP(){Forget(cN2
UnsafeSetP(Ref*newp){p=newp;}
void
swap(xP<Ref>&b){Ref*tmp=p;p=b.p;b.p=tmp;}
private:inline
static
void
Have(Ref*p2);inline
void
iC2;inline
void
xA3
inline
void
Set(Ref*p2);private:Ref*p;}
;nG
iC2{if(!p)return;p->xB3-=1;if(!p->xB3)delete
p;}
nG
Have(Ref*p2){if(p2)++(p2->xB3);}
nG
Birth(){Have(p);}
nG
Set(Ref*p2){Have(p2);iC2;p=p2;}
#endif
#include <utility>
e72
Compare2ndRev{nN1
T>inline
iD2()iS1
T&xC3
T&b
c01
a.second>b.i63}
}
;e72
Compare1st{nN1
c6
const
nO1
xC3
nO1
b
c01
a.first<b.first;}
nN1
c6
const
nO1
a,T1
b
c01
a.first<b;}
nN1
c6
T1
xC3
nO1
b
c01
a<b.first;}
}
;
#ifndef FPoptimizerHashHH
#define FPoptimizerHashHH
#ifdef _MSC_VER
typedef
x83
long
long
xE1;
#define FPHASH_CONST(x) x##ULL
#else
#include <stdint.h>
typedef
uint_fast64_t
xE1;
#define FPHASH_CONST(x) x##ULL
#endif
l33
FUNCTIONPARSERTYPES{e72
fphash_t{xE1
hash1,hash2;fphash_t():hash1(0),hash2(0){}
fphash_t
iS1
xE1&xC3
xE1&b):hash1(a),hash2(b){}
iD2==iS1
fphash_t&yZ1==e82&&hash2==e92
iD2!=iS1
fphash_t&yZ1!=e82||hash2!=e92
iD2<iS1
fphash_t&yZ1!=e82?hash1<e82:hash2<e92}
;}
#endif
#ifndef FPOptimizer_CodeTreeHH
#define FPOptimizer_CodeTreeHH
#ifdef FP_SUPPORT_OPTIMIZER
#include <vector>
#include <utility>
l33
lA1{e72
Grammar;}
l33
xK1{tK1
class
ByteCodeSynth;}
t5{tK1
class
c02
yO1
e72
xK2
yO1
class
c02{typedef
xP<xK2
xF>DataP;DataP
data;e43
c02();~c02();e72
OpcodeTag{}
;e5
iU1
o,OpcodeTag);e72
FuncOpcodeTag{}
;e5
iU1
o,x83
f,FuncOpcodeTag);e72
xD3{}
;e5
tV1,xD3);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
e5
Value_t&&v,xD3);
#endif
e72
VarTag{}
;e5
x83
varno,VarTag);e72
CloneTag{}
;e5
tW1
b,CloneTag);void
GenerateFrom
iS1
x93
FunctionParserBase
xF::Data&data,bool
keep_powi=false);void
GenerateFrom
iS1
x93
FunctionParserBase
xF::Data&data,const
x5&xH2,bool
keep_powi=false);void
SynthesizeByteCode(eO3
x83>&cT3,std
xM3
xF&immed,size_t&stacktop_max);void
SynthesizeByteCode(xK1::eP3&synth,bool
MustPopTemps=true)const;size_t
SynthCommonSubExpressions(xK1::xI1
const;void
SetParams
iS1
x5&xE3
SetParamsMove(x5&tO1
c02
GetUniqueRef();
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void
SetParams(x5&&tO1
#endif
void
SetParam
iZ1
which,tW1
b);void
nB1
size_t
which,c02&b);void
AddParam(tW1
param);void
AddParamMove(c02&param);void
AddParams
iS1
x5&xE3
AddParamsMove(x5&xE3
AddParamsMove(x5&n12,size_t
n22);void
i91
size_t
index);void
DelParams();void
Become(tW1
b);inline
size_t
GetParamCount(c01
lJ2)eJ3;y81
c02&GetParam
iZ1
n)yP
lJ2)[n];y81
tW1
GetParam
iZ1
n
c01
lJ2)[n];y81
void
eL3
iU1
o)iZ3
Opcode=o;y81
iU1
GetOpcode()yO
Opcode;y81
nB
fphash_t
GetHash()yO
Hash;y81
const
x5&lJ2
c01
y1;y81
x5&lJ2)yP
y1;y81
size_t
GetDepth()yO
Depth;y81
const
Value_t&GetImmed()yO
Value;y81
x83
GetVar()yO
lK2
y81
x83
GetFuncNo()yO
lK2
y81
bool
IsDefined(c01
GetOpcode()!=nB
cNop;y81
bool
IsImmed(c01
GetOpcode()==nB
cImmed;y81
bool
IsVar(c01
GetOpcode()==nB
iU2;y81
x83
GetRefCount()yO
xB3;}
void
ReplaceWithImmed(tX1;void
e33
bool
constantfolding=true);void
Sort();inline
void
Mark_Incompletely_Hashed()iZ3
Depth=0;y81
bool
Is_Incompletely_Hashed()yO
Depth==0;y81
const
tR
GetOptimizedUsing()yO
lM2;y81
void
SetOptimizedUsing
iS1
tR
g)iZ3
lM2=g;}
bool
RecreateInversionsAndNegations(bool
prefer_base2=false);void
tE3;void
swap(c02&b){data.swap(b.data);}
bool
IsIdenticalTo(tW1
b)const;void
lD1}
yO1
e72
xK2{int
xB3;iU1
Opcode
iK2
Value;x83
lK2
eK
Params;nB
fphash_t
Hash;size_t
Depth;const
tR
lM2;xK2();xK2
iS1
xK2&b);iA
iU1
o);iA
iU1
o,x83
f);iA
tX1;
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iA
Value_t&&i);xK2(xK2&&b);
#endif
bool
IsIdenticalTo
iS1
xK2&b)const;void
Sort();void
Recalculate_Hash_NoRecursion();private:void
eM1=iS1
xK2&b);}
yO1
c0
CodeTreeImmed(tX1
n21
i
y8
xD3());}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
cC1
CodeTreeImmed
cX3&&i)n21
tF2
i)y8
xD3());}
#endif
cC1
CodeTreeOp(iU1
opcode)n21
opcode
y8
OpcodeTag());}
cC1
CodeTreeFuncOp(iU1
opcode,x83
f)n21
opcode,f
y8
FuncOpcodeTag());}
cC1
CodeTreeVar
lT1
varno)n21
varno
y8
VarTag());}
#ifdef FUNCTIONPARSER_SUPPORT_DEBUGGING
xL1
DumpHashes(xE);xL1
DumpTree(xE);xL1
DumpTreeWithIndent(xE,const
eM3&indent="\\"
);
#endif
}
#endif
#endif
#ifndef FPOptimizer_GrammarHH
#define FPOptimizer_GrammarHH
#include <iostream>
t5{tK1
class
c02;}
l33
lA1{enum
ImmedConstraint_Value{ValueMask=0x07,Value_AnyNum=0x0,x62=0x1,Value_OddInt=0x2,i11=0x3,Value_NonInteger=0x4,eY1=0x5}
;enum
ImmedConstraint_Sign{SignMask=0x18,Sign_AnySign=0x00,nD1=0x08,eZ1=0x10,Sign_NoIdea=0x18}
;enum
ImmedConstraint_Oneness{OnenessMask=0x60,Oneness_Any=0x00,Oneness_One=0x20,Oneness_NotOne=0x40}
;enum
ImmedConstraint_Constness{ConstnessMask=0x180,Constness_Any=0x00,i01=0x80,Constness_NotConst=0x100}
;enum
Modulo_Mode{Modulo_None=0,Modulo_Radians=1}
;enum
Situation_Flags{LogicalContextOnly=0x01,NotForIntegers=0x02,OnlyForIntegers=0x04,OnlyForComplex=0x08,NotForComplex=0x10}
;enum
nZ2{NumConstant,ParamHolder,SubFunction}
;enum
ParamMatchingType{PositionalParams,SelectedParams,AnyParams,GroupFunction}
;enum
RuleType{ProduceNewTree,ReplaceParams}
;
#ifdef __GNUC__
# define PACKED_GRAMMAR_ATTRIBUTE __attribute__((packed))
#else
# define PACKED_GRAMMAR_ATTRIBUTE
#endif
typedef
std::pair<nZ2,const
void*>eA2
yO1
eA2
ParamSpec_Extract
lT1
paramlist,lJ1)yO1
bool
ParamSpec_Compare
iS1
void*xC3
void*b,nZ2
type);x83
ParamSpec_GetDepCode
iS1
eA2&b);e72
ParamSpec_ParamHolder{lJ1:8;x83
constraints:9;x83
depcode:15;e2
tK1
e72
ParamSpec_NumConstant
l14
constvalue;x83
modulo;}
;e72
l71{x83
param_count:2;x83
param_list:30;iU1
subfunc_opcode:8;ParamMatchingType
match_type:3;x83
n1:5;e2
e72
ParamSpec_SubFunction{l71
data;x83
constraints:9;x83
depcode:7;e2
e72
Rule{RuleType
ruletype:2;x83
situation_flags:5;x83
repl_param_count:2+9;x83
repl_param_list:30;l71
match_tree;e2
e72
Grammar{x83
rule_count;x83
short
rule_list[999
cT
extern
const
Rule
grammar_rules[];}
xL1
DumpParam
iS1
eA2&p,std::ostream&o=cV2);xL1
DumpParams
lT1
paramlist,x83
count,std::ostream&o=cV2);}
#endif
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
#define CONSTANT_POS_INF HUGE_VAL
#define CONSTANT_NEG_INF (-HUGE_VAL)
l33
FUNCTIONPARSERTYPES{tK1
inline
Value_t
fp_const_pihalf()yP
fp_const_pi
xF()*yF2;}
tK1
inline
Value_t
fp_const_twopi()eQ3
fp_const_pi
xF());nS3
xO
fp_const_twoe()eQ3
fp_const_e
xF());nS3
xO
fp_const_twoeinv()eQ3
fp_const_einv
xF());nS3
xO
fp_const_negativezero()yP-Epsilon
xF::value;}
}
#ifdef FP_SUPPORT_OPTIMIZER
#include <vector>
#include <utility>
#include <iostream>
nG1{using
l33
lA1;using
t5;using
l33
FUNCTIONPARSERTYPES
yO1
class
MatchInfo{e43
eO3
std::pair<bool,eK> >lQ;eK
cA;eO3
x83>tT;e43
MatchInfo():lQ(),cA(),tT(){}
e43
bool
SaveOrTestRestHolder
lT1
n1,eA3&iJ1){cT1{lQ
xF3
n1+1);lQ
tS=iJ1
l43
if(lQ[n1
eH3==false){lQ
tS=iJ1
l43
eA3&found=lQ[n1
eI3;if(iJ1
eJ3!=found
eJ3
cQ
for
iZ1
a=0;a<iJ1
eJ3;++a)if(!iJ1[a]xI
found[a])cQ
lD2}
void
SaveRestHolder
lT1
n1,eK&iJ1){cT1
lQ
xF3
n1+1);lQ
tS.swap(iJ1);}
bool
SaveOrTestParamHolder
lT1
x0,iT1&xG3){if(cA
eJ3<=x0){cA.xH3
x0+1);cA
xF3
x0);cA
c52
xG3
yQ2
if(!cA[x0].nX2){cA[x0]=xG3
l43
return
xG3
xI
cA[x0]cN2
SaveMatchedParamIndex(lJ1){tT
c52
index);}
iT1&GetParamHolderValueIfFound
lT1
x0)const{static
iT1
dummytree;if(cA
eJ3<=x0)return
dummytree
i1
cA[x0];}
iT1&GetParamHolderValue
lT1
x0
c01
cA[x0];}
bool
HasRestHolder
lT1
n1
c01
lQ
eJ3>n1&&lQ[n1
eH3==true;}
eA3&GetRestHolderValues
lT1
n1)const{static
eA3
empty_result;cT1
return
empty_result
i1
lQ[n1
eI3;}
const
eO3
x83>&GetMatchedParamIndexes(c01
tT;}
void
swap(tC
b){lQ.swap(b.lQ);cA.swap(b.cA);tT.swap(b.tT);}
tC
eM1=iS1
tC
b){lQ=b.lQ;cA=b.cA;tT=b.tT
i1*this;}
}
;class
e6;typedef
xP<e6>cZ;class
e6{e43
int
xB3;e43
e6():xB3(0){}
virtual~e6(){}
}
;e72
n31{bool
found;cZ
specs;n31(bool
f):found(f),specs(){}
n31(bool
f,const
cZ&s):found(f),specs(s){}
}
;xL1
SynthesizeRule(t41
nP1
tC
info)yO1
n31
TestParam
iS1
eA2&yA2
const
nP1
const
cZ&start_at,tC
info)yO1
n31
TestParams(eX&nN,const
nP1
const
cZ&start_at,tC
info,bool
iX1
yO1
bool
ApplyGrammar
iS1
Grammar&tK2,FPoptimizer_CodeTree::nP1
bool
from_logical_context=false);xL1
ApplyGrammars(FPoptimizer_CodeTree::eR
yO1
bool
IsLogisticallyPlausibleParamsMatch(eX&params,const
eR;}
l33
lA1{xL1
DumpMatch(t41
nO,const
FPoptimizer_Optimize::tC
info,bool
DidMatch,std::ostream&o=cV2);xL1
DumpMatch(t41
nO,const
FPoptimizer_Optimize::tC
info,e32
tO3,std::ostream&o=cV2);}
#endif
#include <string>
e42
lA1::nZ2
yT1=false);e42
iU1
yT1=false);
#include <string>
#include <sstream>
#include <assert.h>
#include <iostream>
using
l33
lA1;using
l33
FUNCTIONPARSERTYPES;e42
lA1::nZ2
yT1){
#if 1
e32
p=0;e23
opcode){case
NumConstant:p="NumConstant"
;lC
ParamHolder:p="ParamHolder"
;lC
SubFunction:p="SubFunction"
;xY3
std::ostringstream
tmp;assert(p);tmp<<p;if(pad)while(tmp.str()eJ3<12)tmp<<' '
i1
tmp.str();
#else
std::ostringstream
tmp;tmp<<opcode;if(pad)while(tmp.str()eJ3<5)tmp<<' '
i1
tmp.str();
#endif
}
e42
iU1
yT1){
#if 1
e32
p=0;e23
opcode){case
cAbs:p="cAbs"
;lC
cAcos:p="cAcos"
;lC
cAcosh:p="cAcosh"
;lC
cArg:p="cArg"
;lC
cAsin:p="cAsin"
;lC
cAsinh:p="cAsinh"
;lC
cAtan:p="cAtan"
;lC
cAtan2:p="cAtan2"
;lC
cAtanh:p="cAtanh"
;lC
cCbrt:p="cCbrt"
;lC
cCeil:p="cCeil"
;lC
cConj:p="cConj"
;lC
cCos:p="cCos"
;lC
cCosh:p="cCosh"
;lC
cCot:p="cCot"
;lC
cCsc:p="cCsc"
;lC
cExp:p="cExp"
;lC
cExp2:p="cExp2"
;lC
cFloor:p="cFloor"
;lC
cHypot:p="cHypot"
;lC
cIf:p="cIf"
;lC
cImag:p="cImag"
;lC
cInt:p="cInt"
;lC
cLog:p="cLog"
;lC
cLog2:p="cLog2"
;lC
cLog10:p="cLog10"
;lC
cMax:p="cMax"
;lC
cMin:p="cMin"
;lC
cPolar:p="cPolar"
;lC
cPow:p="cPow"
;lC
cReal:p="cReal"
;lC
cSec:p="cSec"
;lC
cSin:p="cSin"
;lC
cSinh:p="cSinh"
;lC
cSqrt:p="cSqrt"
;lC
cTan:p="cTan"
;lC
cTanh:p="cTanh"
;lC
cTrunc:p="cTrunc"
;lC
cImmed:p="cImmed"
;lC
cJump:p="cJump"
;lC
cNeg:p="cNeg"
;lC
cAdd:p="cAdd"
;lC
cSub:p="cSub"
;lC
cMul:p="cMul"
;lC
cDiv:p="cDiv"
;lC
cMod:p="cMod"
;lC
cEqual:p="cEqual"
;lC
i51:p="cNEqual"
;lC
cLess:p="cLess"
;lC
cLessOrEq:p="cLessOrEq"
;lC
cGreater:p="cGreater"
;lC
cGreaterOrEq:p="cGreaterOrEq"
;lC
cNot:p="cNot"
;lC
cAnd:p="cAnd"
;lC
cOr:p="cOr"
;lC
cDeg:p="cDeg"
;lC
cRad:p="cRad"
;lC
cFCall:p="cFCall"
;lC
cPCall:p="cPCall"
;break;
#ifdef FP_SUPPORT_OPTIMIZER
case
cFetch:p="cFetch"
;lC
cPopNMov:p="cPopNMov"
;lC
cQ3:p="cLog2by"
;lC
cNop:p="cNop"
;break;
#endif
case
cSinCos:p="cSinCos"
;lC
cSinhCosh:p="cSinhCosh"
;lC
cC3:p="cAbsNot"
;lC
cAbsNotNot:p="cAbsNotNot"
;lC
cAbsAnd:p="cAbsAnd"
;lC
cAbsOr:p="cAbsOr"
;lC
cAbsIf:p="cAbsIf"
;lC
cDup:p="cDup"
;lC
cInv:p="cInv"
;lC
cSqr:p="cSqr"
;lC
cRDiv:p="cRDiv"
;lC
cRSub:p="cRSub"
;lC
cNotNot:p="cNotNot"
;lC
cRSqrt:p="cRSqrt"
;lC
iU2:p="VarBegin"
;xY3
std::ostringstream
tmp;assert(p);tmp<<p;if(pad)while(tmp.str()eJ3<12)tmp<<' '
i1
tmp.str();
#else
std::ostringstream
tmp;tmp<<opcode;if(pad)while(tmp.str()eJ3<5)tmp<<' '
i1
tmp.str();
#endif
}
#ifdef FP_SUPPORT_OPTIMIZER
#include <vector>
#include <utility>
#ifndef FP_GENERATING_POWI_TABLE
enum{MAX_POWI_BYTECODE_LENGTH=20}
;
#else
enum{MAX_POWI_BYTECODE_LENGTH=999}
;
#endif
enum{MAX_MULI_BYTECODE_LENGTH=3}
;l33
xK1{tK1
class
ByteCodeSynth{e43
ByteCodeSynth():eN1(),Immed(),cI(),xQ(0),StackMax(0){eN1.xH3
64);Immed.xH3
8);cI.xH3
16
cN2
Pull(eO3
x83>&bc,std
xM3
xF&imm,size_t&StackTop_max){for
lT1
a=0;a<n41;++a){eN1[a]&=~0x80000000u;}
eN1.swap(bc);Immed.swap(imm);StackTop_max=StackMax;}
size_t
GetByteCodeSize(c01
n41;}
size_t
GetStackTop(c01
xQ;}
void
PushVar
lT1
varno){eN1
c52
varno);xI3
1
cN2
PushImmed
cX3
immed
nL
eN1
c52
cImmed);Immed
c52
immed);xI3
1
cN2
StackTopIs(nO,int
offset=0){if((int)xQ>offset){cI[xQ
nK2
first=true;cI[xQ
nK2
second=tree;}
}
bool
IsStackTop(nO,int
offset=0
c01(int)xQ>offset&&cI[xQ
nK2
first&&cI[xQ
nK2
second
xI
tree);y81
void
EatNParams
lT1
eat_count){xQ-=eat_count;}
void
ProducedNParams
lT1
produce_count){xI3
produce_count
cN2
DoPopNMov
iZ1
eB2,size_t
srcpos
nL
eN1
c52
cPopNMov
e53
eB2
e53
srcpos);xM1
srcpos+1);cI[eB2]=cI[srcpos];xM1
eB2+1
cN2
DoDup
iZ1
xJ3
nL
if(xJ3==xQ-1){eN1
c52
cDup);}
else{eN1
c52
cFetch
e53
xJ3);}
xI3
1);cI[xQ-1]=cI[xJ3];}
#ifdef FUNCTIONPARSER_SUPPORT_DEBUGGING
tP1
int>void
Dump(){std::ostream&o=cV2;o<<"Stack state now("
<<xQ<<"):\n"
e73
0;a<xQ;++a){o<<a<<": "
;if(cI[a
eH3){nO=cI[a
eI3;o<<'['<<std::hex<<(void*)(&tree.lJ2))<<std::dec<<','<<tree.GetRefCount()<<']'
iL2
tree,o);}
else
o<<"?"
iV3}
o<<std::flush;}
#endif
size_t
xK3
nO)const{for
iZ1
a=xQ;a-->0;)if(cI[a
eH3&&cI[a
eI3
xI
tree
y03
a
i1~size_t(0);}
bool
Find(nO
c01
xK3
tree)!=~size_t(0);}
bool
FindAndDup(nO){size_t
pos=xK3
tree);if(pos!=~size_t(0)){
#ifdef DEBUG_SUBSTITUTIONS
cV2<<iX3"duplicate at ["
<<pos<<"]: "
iL2
tree
lE2" -- issuing cDup or cFetch\n"
;
#endif
DoDup(pos
yQ2
return
t23
e72
IfData{size_t
ofs;}
;void
SynthIfStep1
c62,iU1
op
x21
c72=n41;eN1
c52
op
eO
eO
cN2
SynthIfStep2
c62
x21
eN1
iK1
xL3+2);eN1
iK1
2
y5
lN2
c72=n41;eN1
c52
cJump
eO
eO
cN2
SynthIfStep3
c62
x21
eN1.back()|=0x80000000u;eN1
iK1
xL3-1);eN1
iK1
2
y5
lN2
xI3
1
iY1
0;a<c72;++a){if(eN1[a]==cJump&&eN1[a+1]==(0x80000000u|(c72-1))){eN1[a+xL3-1);eN1[a+2
y5
lN2
c73(eN1[a]){case
cAbsIf:case
cIf:case
cJump:case
cPopNMov:a+=2;lC
cFCall:case
cPCall:case
cFetch:a+=1;break;yF3
xY3}
}
protected:void
xM1
size_t
value){xQ=value;if(xQ>l53{StackMax=xQ;cI
xF3
l53;}
}
protected:eO3
x83>eN1;std
xM3
xF
Immed;eO3
std::pair<bool,FPoptimizer_CodeTree::yZ2> >cI;size_t
xQ;size_t
StackMax;private:void
incStackPtr(){if(xQ+2>l53
cI
xF3
StackMax=xQ+2);}
tP1
bool
IsIntType,bool
IsComplexType>e72
c82{}
;e43
void
AddOperation
eZ2,x83
eat_count,x83
produce_count=1){EatNParams(eat_count);nR1(opcode);ProducedNParams(produce_count
cN2
nR1
eZ2,c82<false,false>yQ
false,true>yQ
true,false>yQ
true,true>);inline
void
nR1
eZ2){nR1(opcode,c82<bool(nB
IsIntType
xF::nS3),bool(nB
IsComplexType
xF::nS3)>());}
}
yO1
e72
SequenceOpCode
yO1
e72
tU1{static
cG
AddSequence;static
cG
MulSequence;}
;xL1
x01
long
count,cG&eQ,xI1;}
#endif
#ifdef FP_SUPPORT_OPTIMIZER
using
l33
FUNCTIONPARSERTYPES;l33
xK1{tK1
e72
SequenceOpCode
l14
basevalue;x83
op_flip;x83
op_normal,op_normal_flip;x83
op_inverse,op_inverse_flip;}
yO1
cG
tU1
xF::AddSequence={xH1,cNeg
x9
cAdd,cSub,cRSub}
yO1
cG
tU1
xF::MulSequence={e62
1),cInv,cMul,cMul,cDiv,cRDiv}
;
#define findName(a,b,c) "var"
#define TryCompilePowi(o) false
#define mData this
#define mByteCode eN1
#define mImmed Immed
nL2
false,false>)x31
# define FP_FLOAT_VERSION 1
# define FP_COMPLEX_VERSION 0
# include "extrasrc/fp_opcode_add.inc"
# undef FP_COMPLEX_VERSION
# undef FP_FLOAT_VERSION
}
nL2
true,false>)x31
# define FP_FLOAT_VERSION 0
# define FP_COMPLEX_VERSION 0
# include "extrasrc/fp_opcode_add.inc"
# undef FP_COMPLEX_VERSION
# undef FP_FLOAT_VERSION
}
#ifdef FP_SUPPORT_COMPLEX_NUMBERS
nL2
false,true>)x31
# define FP_FLOAT_VERSION 1
# define FP_COMPLEX_VERSION 1
# include "extrasrc/fp_opcode_add.inc"
# undef FP_COMPLEX_VERSION
# undef FP_FLOAT_VERSION
}
nL2
true,true>)x31
# define FP_FLOAT_VERSION 0
# define FP_COMPLEX_VERSION 1
# include "extrasrc/fp_opcode_add.inc"
# undef FP_COMPLEX_VERSION
# undef FP_FLOAT_VERSION
}
#endif
#undef findName
#undef mImmed
#undef mByteCode
#undef mData
#undef TryCompilePowi
}
using
l33
xK1;
#define POWI_TABLE_SIZE 256
#define POWI_WINDOW_SIZE 3
l33
xK1{
#ifndef FP_GENERATING_POWI_TABLE
extern
const
x83
char
powi_table[POWI_TABLE_SIZE];const
#endif
x83
char
powi_table[POWI_TABLE_SIZE]={0,1,1,1,2,1,2,1,xN3
4,1,2,xP3
2,1,xN3
8,cV3
xQ3
15,1,16,1,2,1,4,1,2,xP3
2,1,4,cV3
1,16,1,25,xQ3
27,5,8,3,2,1,30,1,31,3,32,1,2,1,xN3
8,1,2,xQ3
39,1,16,137,2,1,4,cV3
xP3
45,135,4,31,2,5,32,1,2,131,50,1,51,1,8,3,2,1,54,1,55,3,16,1,57,133,4,137,2,135,60,1,61,3,62,133,63,1,iL1
131,iL1
139,lO2
e7
30,1,130,137,2,31,lO2
e7
e7
130,cV3
1,e7
e7
2,1,130,133,iL1
61,130,133,62,139,130,137,e7
lO2
e7
e7
iL1
131,e7
e7
130,131,2,133,lO2
130,141,e7
130,cV3
1,e7
5,135,e7
lO2
e7
lO2
130,133,130,141,130,131,e7
e7
2,131}
;}
static
x03
c1=256;
#define FPO(x)
l33{class
PowiCache{private:int
iM[c1];int
iM1[c1];e43
PowiCache():iM(),iM1(){iM[1]=1;}
bool
Plan_Add(c11,int
count){cD1>=c1
cQ
iM1[t02+=count
i1
iM[t02!=0;}
void
l63
c11){cD1<c1)iM[t02=1;}
void
Start
iZ1
value1_pos){for(int
n=2;n<c1;++n)iM[n]=-1;Remember(1,value1_pos);DumpContents();}
int
Find(c11)const{cD1<c1){if(iM[t02>=0){FPO(iC3(iG3,"* I found %ld from cache (%u,%d)\n",value,(unsigned)cache[value],iD3 value]))i1
iM[t02;}
eE3-1;}
void
Remember(c11,size_t
iQ3){cD1>=c1)return;FPO(iC3(iG3,"* Remembering that %ld can be found at %u (%d uses remain)\n",value,(unsigned)iQ3,iD3 value]));iM[t02=(int)iQ3;}
void
DumpContents()const{FPO(for(int a=1;a<POWI_CACHE_SIZE;++a)if(cache[a]>=0||iD3 a]>0){iC3(iG3,"== cache: sp=%d, val=%d, needs=%d\n",cache[a],a,iD3 a]);})}
int
UseGetNeeded(c11){cD1>=0&&value<c1)return--iM1[t02
i1
0;}
}
yO1
size_t
y6
long
count
iQ1
cG&eQ,xI1;xL1
c21
size_t
apos,long
aval,size_t
bpos,long
bval
iQ1
x83
cumulation_opcode,x83
cimulation_opcode_flip,xI1;void
lB1
c11
iQ1
int
need_count,int
lC1=0){cD1<1)return;
#ifdef FP_GENERATING_POWI_TABLE
if(lC1>32)throw
false;
#endif
if(iM.Plan_Add(value,need_count
y03;long
xR3
1;cD1<POWI_TABLE_SIZE){xR3
powi_table[t02
xZ3&128){half&=127
xZ3&64)xR3-t12
FPO(iC3(iG3,"value=%ld, half=%ld, otherhalf=%ld\n",value,half,value/half));lB1
half
xO3
iM.l63
half)i1;}
iP1
half&64){xR3-t12}
}
else
cD1&1)xR3
value&((1<<POWI_WINDOW_SIZE)-1);else
xR3
value/2;long
cL=value-half
xZ3>cL||half<0)std::swap(half,cL);FPO(iC3(iG3,"value=%ld, half=%ld, otherhalf=%ld\n",value,half,otherhalf))xZ3==cL){lB1
half,iM,2,lC1+1);}
else{lB1
half
xO3
lB1
cL>0?cL:-cL
xO3}
iM.l63
value);}
tK1
size_t
y6
c11
iQ1
cG&eQ,xI1{int
xT3=iM.Find(value);if(xT3>=0)yP
xT3;}
long
xR3
1;cD1<POWI_TABLE_SIZE){xR3
powi_table[t02
xZ3&128){half&=127
xZ3&64)xR3-t12
FPO(iC3(iG3,"* I want %ld, my plan is %ld * %ld\n",value,half,value/half));size_t
xM2=y6
half
cE1
if(iM
lP2
half)>0||xM2!=cG1){iN1
xM2)xP2
half,cG1);}
x01
value/half
e63
size_t
iQ3=cG1
xP2
value,iQ3);iM.DumpContents()i1
iQ3;}
iP1
half&64){xR3-t12}
}
else
cD1&1)xR3
value&((1<<POWI_WINDOW_SIZE)-1);else
xR3
value/2;long
cL=value-half
xZ3>cL||half<0)std::swap(half,cL);FPO(iC3(iG3,"* I want %ld, my plan is %ld + %ld\n",value,half,value-half))xZ3==cL){size_t
xM2=y6
half
cE1
c21
xM2,half,xM2,half,iM,eQ.op_normal,eQ.op_normal_flip,c92}
else{long
part1=half;long
part2=cL>0?cL:-cL;size_t
part1_pos=y6
part1
cE1
size_t
part2_pos=y6
part2
cE1
FPO(iC3(iG3,"Subdivide(%ld: %ld, %ld)\n",value,half,otherhalf));c21
part1_pos,part1,part2_pos,part2,iM,cL>0?eQ.op_normal:eQ.op_inverse,cL>0?eQ.op_normal_flip:eQ.op_inverse_flip,c92}
size_t
iQ3=cG1
xP2
value,iQ3);iM.DumpContents()i1
iQ3;}
xL1
c21
size_t
apos,long
aval,size_t
bpos,long
bval
iQ1
x83
cumulation_opcode,x83
cumulation_opcode_flip,xI1{int
a_needed=iM
lP2
aval);int
xU3=iM
lP2
bval);bool
flipped
eW3
#define DUP_BOTH() do{if(apos<bpos){size_t tmp=apos;apos=bpos;bpos=tmp e41 FPO(iC3(iG3,"-> " iO3 iO3"op\n",(unsigned)apos,(unsigned)bpos));iN1 apos);iN1 apos==bpos?cG1:bpos);}while(0)
#define DUP_ONE(p) do{FPO(iC3(iG3,"-> " iO3"op\n",(unsigned)p));iN1 p);}while(0)
if(a_needed>0){if(xU3>0){nM2}
cJ3
bpos!=cG1)nM2
else{x02
e41}
}
iP1
xU3>0){if(apos!=cG1)nM2
else
DUP_ONE(bpos);}
cJ3
apos==bpos&&apos==cG1)x02;iP1
apos==cG1&&bpos==xV3
2){FPO(iC3(iG3,"-> op\n"))e41
iP1
apos==xV3
2&&bpos==cG1)FPO(iC3(iG3,"-> op\n"));iP1
apos==cG1)DUP_ONE(bpos);iP1
bpos==cG1){x02
e41
else
nM2}
yB1
flipped?cumulation_opcode_flip:cumulation_opcode,2);}
xL1
cH1
long
count,cG&eQ,xI1{while
cW3<256){int
xR3
xK1::powi_table[count]xZ3&128){half&=127;cH1
half
e63
count/=half;}
else
xY3
if
cW3==1)return;if(!cW3&1)){yB1
cSqr,1);cH1
count/2
e63}
else{iN1
cG1);cH1
count-1
e63
yB1
cMul,2);}
}
}
l33
xK1{xL1
x01
long
count,cG&eQ,xI1{if
cW3==0)t71
eQ.basevalue);else{bool
t22
eW3
if
cW3<0){t22=true;count=-count;}
if(false)cH1
count
e63
iP1
count>1){PowiCache
iM;lB1
count,iM,1);size_t
xO1=synth.GetStackTop();iM.Start(cG1);FPO(iC3(iG3,"Calculating result for %ld...\n",count));size_t
xN2=y6
count
cE1
size_t
n_excess=xV3
xO1;if(n_excess>0||xN2!=xO1-1){synth.DoPopNMov(xO1-1,xN2);}
}
if(t22)yB1
eQ.op_flip,1);}
}
}
#endif
#ifndef FPOptimizer_ValueRangeHH
#define FPOptimizer_ValueRangeHH
t5{l33
l73{l01
e72
Comp{}
;tP1>e72
Comp<nB
cLess>l83<nA
cLessOrEq>l83<=nA
cGreater>l83>nA
cGreaterOrEq>l83>=nA
cEqual>l83==nA
i51>l83!=b;}
}
;}
tK1
e72
cI1
l14
val;bool
known;cI1():val(),known(false){}
cI1(tV1):val(v),known(true){y81
l93
tV1){known=true;val=v;}
l93
xW3
Value_t),cI1
y7)val=iE2
l93
xW3
const
Value_t&),cI1
y7)val=iE2
l01
void
set_if
cX3
v,xW3
Value_t),cI1
y7&&l73::Comp<Compare>()(val,v))val=iE2
l01
void
set_if(tV1,xW3
const
Value_t&),cI1
y7&&l73::Comp<Compare>()(val,v))val=iE2}
yO1
e72
range{cI1
xF
min,max;range():min(),max(){}
range
cX3
mi,Value_t
ma):min(mi),max(ma){}
range(bool,Value_t
ma):min(),max(ma){}
range
cX3
mi,bool):min(mi),max(){}
void
set_abs();void
set_neg();}
yO1
bool
IsLogicalTrueValue
iS1
yD3&p,bool
abs)yO1
bool
IsLogicalFalseValue
iS1
yD3&p,bool
abs);}
#endif
#ifndef FPOptimizer_RangeEstimationHH
#define FPOptimizer_RangeEstimationHH
t5{enum
TriTruthValue{iF2,xX3,Unknown}
yO1
yD3
CalculateResultBoundaries
iS1
eR
yO1
bool
IsLogicalValue
iS1
eR
yO1
TriTruthValue
GetIntegerInfo
iS1
eR
yO1
xP1
GetEvennessInfo
iS1
eR{if(!tree
tD1)return
Unknown;yL1=tree
x41;if(nB
isEvenInteger(value
y13
nB
isOddInteger(value
y23
tK1
xP1
GetPositivityInfo
iS1
eR{yD3
p=CalculateResultBoundaries(tree);if(p
yI&&p
yM>=e62
y13
p
e61
l61
y23
tK1
xP1
GetLogicalValue
iS1
nP1
bool
abs){yD3
p=CalculateResultBoundaries(tree);if(IsLogicalTrueValue(p,abs
y13
IsLogicalFalseValue(p,abs
y23}
#endif
#ifndef FPOptimizer_ConstantFoldingHH
#define FPOptimizer_ConstantFoldingHH
t5{xL1
ConstantFolding(eR;}
#endif
l33{using
l33
FUNCTIONPARSERTYPES;using
t5;e72
ComparisonSetBase{enum{eB3=0x1,Eq_Mask=0x2,Le_Mask=0x3,eC3=0x4,eD3=0x5,Ge_Mask=0x6}
;static
int
Swap_Mask(int
m)yP(m&Eq_Mask)|((m&eB3)?eC3:0)|((m&eC3)?eB3:0);}
enum
c31{Ok,BecomeZero,BecomeOne,n91}
;enum
x12{cond_or,iG2,iH2,iI2}
;}
yO1
e72
ComparisonSet:public
ComparisonSetBase{e72
t32{yZ2
a
tX
b;int
relationship;t32():a(),b(),relationship(){}
}
;eO3
t32>tH;e72
Item{yZ2
value;bool
cA2;Item():value(),cA2(false){}
}
;eO3
Item>cJ1;int
xQ1;ComparisonSet():tH(),cJ1(),xQ1(0){}
c31
AddItem
iR1
a,bool
cA2,x12
type){for
iZ1
c=0;c<cJ1
eJ3;++c)if(cJ1[c].value
xI
a)){if(cA2!=cJ1[c].cA2){l11
cU1
case
iI2:cJ1.erase(cJ1.begin()+c);xQ1
cB2
case
iG2:case
iH2:cW1}
eE3
n91;}
Item
pole;pole.value=a;pole.cA2=cA2;cJ1
c52
pole)i1
Ok;}
c31
AddRelationship(yZ2
a,yZ2
b,int
tY1,x12
type){l11
if(tY1==7)cU1
lC
iI2:if(tY1==7){xQ1
cB2}
lC
iG2:case
iH2:if(tY1==0)cW1
xY3
if(!(a.GetHash()<b.GetHash())){a.swap(b);tY1=Swap_Mask(tY1);}
for
iZ1
c=0;c<tH
eJ3;++c){if(tH[c].a
xI
a)&&tH[c].b
xI
b)){l11{int
y33=xQ2|tY1;if(y33==7)cU1
xQ2=y33;xY3
case
iG2:case
iH2:{int
y33=xQ2&tY1;if(y33==0)cW1
xQ2=y33;xY3
case
iI2:{int
newrel_or=xQ2|tY1;int
xR2=xQ2&tY1;lQ2
5&&xR2==0){xQ2=eD3
i1
n91;}
lQ2
7&&xR2==0){xQ1+=1;tH.erase(tH.begin()+c)i1
n91;}
lQ2
7&&xR2==Eq_Mask){xQ2=Eq_Mask;xQ1
cB2}
yA1}
eE3
n91;}
}
t32
comp;comp.a=a;comp.b=b;comp.relationship=tY1;tH
c52
comp)i1
Ok;}
}
;nN1
Value_t,x93
CondType>bool
ConstantFolding_LogicCommon(nP1
CondType
xF1,bool
xS2){bool
should_regenerate
eW3
ComparisonSet
xF
comp;x51{x93
c8
c31
cY3=c8
Ok;iT1&atree=xW
a);e23
atree
nC){case
cEqual
lG
Eq_Mask
e12
i51
lG
eD3
e12
cLess
lG
eB3
e12
cLessOrEq
lG
Le_Mask
e12
cGreater
lG
eC3
e12
cGreaterOrEq
lG
Ge_Mask
e12
cNot:cY3
cV1
l8
0),true
e12
cNotNot:cY3
cV1
l8
0),false,xF1);break;yF3
if(xS2||IsLogicalValue(atree))cY3
cV1,false,xF1);c73(cY3){ReplaceTreeWithZero:nU
0)i1
true;ReplaceTreeWithOne:nU
1);nZ
c8
Ok:lC
c8
BecomeZero
t7
c8
BecomeOne:iD
c8
n91:c61
xY3}
if(should_regenerate){
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Before ConstantFolding_LogicCommon: "
cR
#endif
if(xS2){tree.DelParams();}
else{for
l41{iT1&atree=xW
a);if(IsLogicalValue(atree))iZ);}
}
for
iZ1
a=0;a<comp.cJ1
eJ3;++a){if(comp.cJ1[a].cA2
lA3
cNot);r.c7
r.lR2
iP1!xS2
lA3
cNotNot);r.c7
r.lR2
else
tree.c7}
for
iZ1
a=0;a<comp.tH
eJ3;++a
lA3
cNop);e23
comp.tH[a
eE){case
c8
eB3:r
iH
cLess);lC
c8
Eq_Mask:r
iH
cEqual);lC
c8
eC3:r
iH
cGreater);lC
c8
Le_Mask:r
iH
cLessOrEq);lC
c8
eD3:r
iH
i51);lC
c8
Ge_Mask:r
iH
cGreaterOrEq
e02
r
c91
comp.tH[a].a);r
c91
comp.tH[a].b);r.lR2
if(comp.xQ1!=0)tree.yA
e62
comp.xQ1)));
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"After ConstantFolding_LogicCommon: "
cR
#endif
lD2
eE3
t23
yP1
ConstantFolding_AndLogic(iM3(tree.GetOpcode()==cAnd||tree.GetOpcode()==cAbsAnd)i1
nI
iG2,true);}
yP1
ConstantFolding_OrLogic(iM3(tree.GetOpcode()==cOr||tree.GetOpcode()==cAbsOr)i1
nI
cond_or,true);}
yP1
ConstantFolding_AddLogicItems(iM3(tree.GetOpcode()==cAdd)i1
nI
iI2,false);}
yP1
ConstantFolding_MulLogicItems(iM3(tree.GetOpcode()==cMul)i1
nI
iH2,false);}
}
#include <vector>
#include <map>
#include <algorithm>
l33{using
l33
FUNCTIONPARSERTYPES;using
t5;e72
CollectionSetBase{enum
xR1{Ok,n91}
;}
yO1
e72
CollectionSet:public
CollectionSetBase{e72
c41{yZ2
value
tX
xT2;bool
e0;c41():value(),xT2(),e0(false){}
c41
iR1
v,iT1&f):value(v),xT2(f),e0(false){}
}
;std::multimap<fphash_t,c41>iN;typedef
x93
std::multimap<fphash_t,c41>::y83
xS1;CollectionSet():iN(){}
xS1
FindIdenticalValueTo
iR1
value){fphash_t
hash=value.GetHash();for(xS1
i=iN.xU2
hash);i!=iN.cX1
hash;++i){cD1
xI
i
eC2.value
y03
i;eE3
iN.end();}
bool
Found
iS1
xS1&b)yP
b!=iN.end();}
xR1
AddCollectionTo
iR1
xT2,const
xS1&into_which){c41&c=into_which
eC2;if(c.e0)c.xT2
cS
xT2);else{yZ2
add;add
iH
cAdd);add
c91
c.xT2);add
cS
xT2);c.xT2.swap(add);c.e0=true;eE3
n91;}
xR1
x22
iR1
value,iT1&xT2){const
fphash_t
hash=value.GetHash();xS1
i=iN.xU2
hash);for(;i!=iN.cX1
hash;++i){if(i
eC2.value
xI
value
y03
AddCollectionTo(xT2,i);}
iN.y43,std::make_pair(hash,c41(value,xT2)))i1
Ok;}
xR1
x22
iR1
a)yP
x22(a,nA1
1)));}
}
yO1
e72
ConstantExponentCollection{typedef
eK
y63;typedef
std::x71
xV2;eO3
xV2>data;ConstantExponentCollection():data(){}
void
MoveToSet_Unique
iS1
Value_t&eP1&eQ1){data
c52
std::x71(eP1()));data.back().second.swap(eQ1
cN2
MoveToSet_NonUnique
iS1
Value_t&eP1&eQ1){x93
eO3
xV2>::y83
i=std::xU2
data.iJ2
data.end(),exponent,Compare1st());if(i!=data.cX1
exponent){i
eC2.y43
eC2.end(),eQ1.iJ2
eQ1.end());}
else{data.y43,std::x71(exponent,eQ1));}
}
bool
iA2{bool
changed
eW3
std::sort(data.iJ2
data.end(),Compare1st());redo:for
iZ1
a=0;a
eR3
a)l14
exp_a=data[a
eH3;lG3
exp_a,e62
1)))yA1
for
iZ1
b=a+1;b
eR3
b)l14
exp_b=data[b
eH3
iK2
xW2=exp_b-exp_a;if(xW2>=fp_abs(exp_a))break
iK2
exp_diff_still_probable_integer=xW2*e62
16);if(t42
exp_diff_still_probable_integer)&&!(t42
exp_b)&&!t42
xW2))){y63&a_set=lS2;y63&b_set=data[b
eI3;
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Before ConstantExponentCollection iteration:\n"
;Dump(cV2);
#endif
if(isEvenInteger(exp_b)&&!isEvenInteger(xW2+exp_a)nQ
tmp2;tmp2
iH
cMul);tmp2
iF1
b_set);tmp2
iW1
tX
tmp;tmp
iH
cAbs);tmp
c91
tmp2);tmp
iW1;b_set
xF3
1);b_set[0
tQ3
tmp);}
a_set.insert(a_set.end(),b_set.iJ2
b_set.end());y63
b_copy=b_set;data.erase(data.begin()+b);MoveToSet_NonUnique(xW2,b_copy);yS1
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"After ConstantExponentCollection iteration:\n"
;Dump(cV2);
#endif
cJ}
}
eE3
changed;}
#ifdef DEBUG_SUBSTITUTIONS
void
Dump(std::ostream&out){for
iZ1
a=0;a
eR3
a){out.precision(12);out<<data[a
eH3<<": "
;e11
lS2
eJ3;++b){if(b>0)out<<'*'
iL2
lS2[b],out);}
out<<std::endl;}
}
#endif
}
yO1
static
yZ2
x81
yZ2&value,bool&xK
yY3
value
nC){case
cPow:{yZ2
eD2
value
l8
1);value.y91
i1
exponent;}
case
cRSqrt:value.y91;xK=true
i1
nA1-0.5))t83
cInv:value.y91;xK=true
i1
nA1-1));yF3
xY3
return
nA1
1));}
cB1
void
eR1
eS1&mul,const
nP1
iT1&xT2,bool&c51
bool&xK){for
iZ1
a=0;a<yC++a
nQ
value(xW
a))tX
exponent(x81
value,xK));if(!xT2
tD1||xT2
x41!=e62
1.0)nQ
cY1;cY1
iH
cMul);cY1
cS
tU2
cY1
cS
xT2);cY1
iW1
eX3.swap(cY1);}
#if 0 /* FIXME: This does not work */
cD1
nC==cMul){if(1){bool
exponent_is_even=exponent
tD1&&isEvenInteger(exponent
x41);e11
value.eZ3{bool
tmp=false
tX
val(value
l8
b))tX
exp(x81
val,tmp));if(exponent_is_even||(exp
tD1&&isEvenInteger(exp
x41))nQ
cY1;cY1
iH
cMul);cY1
cS
tU2
cY1
c91
exp);cY1.ConstantFolding();if(!cY1
tD1||!isEvenInteger(cY1
x41)){goto
cannot_adopt_mul;}
}
}
}
eR1
mul,value,exponent,c51
xK);}
else
cannot_adopt_mul:
#endif
{if(mul.x22(value,exponent)==CollectionSetBase::n91)c61}
}
}
yP1
ConstantFolding_MulGrouping(eR{bool
xK
eW3
bool
should_regenerate
eW3
eS1
mul;eR1
mul
cU3,nA1
1)),c51
xK);typedef
std::pair<yZ2,eK>eT1;typedef
std::multimap<fphash_t,eT1>cK1;cK1
iJ;for(x93
eS1::xS1
j=mul.iN.y73
j!=mul.iN.end();++j
nQ&value=j
eC2.value
tX&eD2
j
eC2.xT2;if(j
eC2.e0)exponent
iW1;const
fphash_t
eU1=exponent.GetHash();x93
cK1::y83
i=iJ.xU2
eU1);for(;i!=iJ.cX1
eU1;++i)if(i
eC2.first
xI
exponent)){if(!exponent
tD1||!cZ1
x41,e62
1)))c61
i
eC2.second
c52
value);goto
skip_b;}
iJ.y43,std::make_pair(eU1,std::make_pair(exponent,eK
iZ1(1),value))));skip_b:;}
#ifdef FP_MUL_COMBINE_EXPONENTS
ConstantExponentCollection
xF
e01;for(x93
cK1::y83
j,i=iJ.y73
i!=iJ.end();i=j){j=i;++j;eT1&list=i
eC2;x32.lV1
eD2
list.first
x41;if(!(exponent==xG1)e01.MoveToSet_Unique(exponent,list
iB2
iJ.erase(i);}
}
if(e01.iA2)c61
#endif
if(should_regenerate
nQ
before=tree;before.lD1
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Before ConstantFolding_MulGrouping: "
iL2
before
lE2"\n"
;
#endif
tree.DelParams();for(x93
cK1::y83
i=iJ.y73
i!=iJ.end();++i){eT1&list=i
eC2;
#ifndef FP_MUL_COMBINE_EXPONENTS
x32.lV1
eD2
list.first
x41;if(exponent==xG1
yA1
if(cZ1
nH2
tree.AddParamsMove(list
iB2
yA1}
}
#endif
yZ2
mul;mul
iH
cMul);mul
iF1
list
iB2
mul
iW1;if(xK&&list.first
tD1){x32
x41==e62
1)/e62
3)nQ
cbrt;cbrt
iH
cCbrt);cbrt.e8
cbrt.lT2
cbrt);yA1
cV
0.5)nQ
sqrt;sqrt
iH
cSqrt);sqrt.e8
sqrt.lT2
sqrt);yA1
cV-0.5)nQ
rsqrt;rsqrt
iH
cRSqrt);rsqrt.e8
rsqrt.lT2
rsqrt);yA1
cV-1)nQ
inv;inv
iH
cInv);inv.e8
inv.lT2
inv);yA1}
}
yZ2
pow;pow
iH
cPow);pow.e8
pow
c91
list.first);pow.lT2
pow);}
#ifdef FP_MUL_COMBINE_EXPONENTS
iJ.clear(iY1
0;a<iB
eJ3;++a)l14
eD2
iB[a
eH3;if(cZ1
nH2
tree.AddParamsMove(iB[a]iB2
yA1}
yZ2
mul;mul
iH
cMul);mul
iF1
iB[a]iB2
mul
iW1
tX
pow;pow
iH
cPow);pow.e8
pow.yA
exponent));pow.lT2
pow);}
#endif
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"After ConstantFolding_MulGrouping: "
cR
#endif
return!tree
xI
before);eE3
t23
yP1
ConstantFolding_AddGrouping(eR{bool
should_regenerate
eW3
eS1
add;x51{if(xW
a)nC==cMul)yA1
if(add.x22(xW
a))==CollectionSetBase::n91)c61}
cY2
lU2
l51);size_t
tD=0;x51{iT1&mulgroup=xW
a);if
eH2
nC==cMul){e11
cA1
eZ3{if
eH2
l8
b)tD1)yA1
x93
eS1::xS1
c=add.FindIdenticalValueTo
eH2
l8
b));if(add.Found(c)nQ
tmp
eH2
y8
CloneTag());tmp.i91
b);tmp
iW1;add.AddCollectionTo(tmp,c);c61
goto
done_a;}
}
lU2[a]=true;tD+=1;done_a:;}
}
if(tD>0){if(tD>1){eO3
std::pair<yZ2,size_t> >nY;std::multimap<fphash_t,size_t>eV1;bool
lB3
eW3
x51
if(lU2[a]){e11
xW
a).eZ3{iT1&p=xW
a)l8
b);const
fphash_t
p_hash=p.GetHash();for(std::multimap<fphash_t,size_t>::const_iterator
i=eV1.xU2
p_hash);i!=eV1.cX1
p_hash;++i){if(nY[i
eC2
eH3
xI
p)){nY[i
eC2
eI3+=1;lB3=true;goto
found_mulgroup_item_dup;}
}
nY
c52
std::make_pair(p,size_t(1)));eV1.insert(std::make_pair(p_hash,nY
eJ3-1));found_mulgroup_item_dup:;}
}
if(lB3
nQ
eE2;{size_t
max=0
eK3
p=0;p<nY
eJ3;++p)if(nY[p
eI3<=1)nY[p
eI3=0;else{nY[p
eI3*=nY[p
eH3
nP2;if(nY[p
eI3>max){eE2=nY[p
eH3;max=nY[p
eI3;}
}
}
yZ2
group_add;group_add
iH
cAdd);
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Duplicate across some trees: "
iL2
eE2
lE2" in "
cR
#endif
x51
if(lU2[a])e11
xW
a).eZ3
if(eE2
xI
xW
a)l8
b))nQ
tmp(xW
a)y8
CloneTag());tmp.i91
b);tmp
iW1;group_add
c91
tmp);lU2[a]eW3
xY3
group_add
iW1
tX
group;group
iH
cMul);group
c91
eE2);group
c91
group_add);group
iW1;add.x22(group);c61}
}
x51
if(lU2[a]){if(add.x22(xW
a))==CollectionSetBase::n91)c61}
}
if(should_regenerate){
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Before ConstantFolding_AddGrouping: "
cR
#endif
tree.DelParams();for(x93
eS1::xS1
j=add.iN.y73
j!=add.iN.end();++j
nQ&value=j
eC2.value
tX&coeff=j
eC2.xT2;if(j
eC2.e0)coeff
iW1;if(coeff
tD1){lG3
coeff
x41,xG1)yA1
lG3
coeff
x41
nH2
tree
c91
value);yA1}
}
yZ2
mul;mul
iH
cMul);mul
c91
value);mul
c91
coeff);mul.e33
yB
e8}
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"After ConstantFolding_AddGrouping: "
cR
#endif
lD2
eE3
t23}
l33{using
l33
FUNCTIONPARSERTYPES;using
t5
yO1
bool
ConstantFolding_IfOperations(iM3(tree.GetOpcode()==cIf||tree.GetOpcode()==cAbsIf);for(;;){if(c93==cNot){tD2
cIf);xW
0).eF2
0)c43
xW
1).swap(xW
2));}
iP1
xW
0)cQ1{tD2
t03;xW
0).eF2
0)c43
xW
1).swap(xW
2));}
else
yV3
lY1
0),t72==t03
tN1
tree.eF2
1));nZ
l03
tree.eF2
2));nZ
lZ1
if(c93==cIf||c93==cAbsIf
nQ
cond=xW
0)tX
lC3;lC3
tE2==cIf?cNotNot:cAbsNotNot);lC3
xX2
1));ConstantFolding(lC3)tX
lD3;lD3
tE2==cIf?cNotNot:cAbsNotNot);lD3
xX2
2));ConstantFolding(lD3);if(lC3
tD1||lD3
tD1
nQ
eT;eT
tE2);eT
xX2
1));eT
tX3
eT.nJ
2));eT
iW1
tX
else_tree
tS1
tE2)tS1
xX2
2))tS1.nJ
1))tS1.nJ
2))tS1
cY
cond
nC
xT1
0,cond
l8
0)yB
nB1
1,eT
yB
nB1
2,else_tree
yQ2}
if(xW
1)nC==xW
2)nC&&(xW
1)nC==cIf||xW
1)nC==t03
nQ&x53=xW
1)tX&leaf2=xW
2);if(x53
l8
0)nN2
0))&&x61
1))||x53
l8
2)nN2
2)))nQ
eT;eT
nO2;eT
tY3
eT
xY2
1));eT
xZ2
1));eT
iW1
tX
else_tree
tS1
nO2
tS1.nJ
0))tS1
xY2
2))tS1
xZ2
2))tS1
cY
x53
nC
xT1
0
cB3
0)yB
nB1
1,eT
yB
nB1
2,else_tree
yQ2
if
x61
1))&&x53
l8
2)nN2
2))nQ
eU;eU
nO2;eU
c91
xW
0));eU
xY2
0));eU
xZ2
0));eU
cY
x53
nC
yB
nB1
0,eU
xT1
2
cB3
2)xT1
1
cB3
1)yQ2
if
x61
2))&&x53
l8
2)nN2
1))nQ
eI2;eI2
iH
leaf2
nC==cIf?cNot:cC3);eI2
xZ2
0));eI2
iW1
tX
eU;eU
nO2;eU
c91
xW
0));eU
xY2
0));eU
c91
eI2);eU
cY
x53
nC
yB
nB1
0,eU
xT1
2
cB3
2)xT1
1
cB3
1)yQ2}
yZ2&xV=xW
1)tX&y4=xW
2);if(xV
xI
y4)){tree.eF2
1)yQ2
const
OPCODE
op1=xV
nC;const
OPCODE
op2=y4
nC;y93
op2){if(xV.e91
1
nQ
lO
0));y02
0))c71()n4
if(xV.e91
2&&y4.e91
2){if(xV
l8
0)xI
y4
l8
0))nQ
param0=xV
l8
0)tX
lO
1));y02
1))c71
t8
param0)n4
if(xV
l8
1)xI
y4
l8
1))nQ
param1=xV
l8
1)tX
lO
0));y02
0))c71
t8
n81
c81
param1
yQ2}
y93
yA3
cMul
lV2
cAnd
lV2
cOr
lV2
cAbsAnd
lV2
cAbsOr
lV2
cMin
lV2
cMax){eK
lE3;c2{for
iZ1
b=y4.l91
b-->0;){if(xV
lF3
y4
l8
b))){if(lE3
eU3){xV.t13
lD1}
lE3
c52
xV
n93
y4.i91
b);xV.i91
a
e02}
}
if(!lE3
eU3){xV
iW1;y4
iW1
l7
op1
yB
SetParamsMove(lE3)n4}
}
y93
yA3
cMul||(op1==cAnd&&IsLogicalValue(y4))||(op1==cOr&&IsLogicalValue(y4))){c2
if(xV
lF3
y4)){xV.lD1
xV.i91
a);xV
iW1
tX
cL1=y4;y4=tE
op1==yA3
cOr
t52
op1
c81
cL1)n4}
if((op1==cAnd
lV2
cOr)&&op2==cNotNot
nQ&lH3=y4
l8
0);c2
if(xV
lF3
lH3)){xV.lD1
xV.i91
a);xV
iW1
tX
cL1=lH3;y4=tE
op1==cOr
t52
op1
c81
cL1)n4}
if(op2==cAdd||op2==cMul||(op2==cAnd&&IsLogicalValue(xV))||(op2==cOr&&IsLogicalValue(xV))){for
iZ1
a=y4
iY
y4
lF3
xV)){y4.t13
i91
a);y4
iW1
tX
cM1=xV;xV=tE
op2==cAdd||op2==cOr
t52
op2
c81
cM1)n4}
if((op2==cAnd||op2==cOr)&&op1==cNotNot
nQ&lI3=xV
l8
0
iY1
y4
iY
y4
lF3
lI3)){y4.t13
i91
a);y4
iW1
tX
cM1=lI3;xV=tE
op2==cOr
t52
op2
c81
cM1)n4
eE3
t23}
#include <limits>
l33{using
l33
FUNCTIONPARSERTYPES;using
t5
yO1
int
maxFPExponent()yP
std::numeric_limits
xF::max_exponent;}
yP1
x91
Value_t
base,Value_t
exponent){if(base<xG1
lD2
lG3
base,xG1||lJ3
base,e62
1))cQ
return
exponent>=e62
maxFPExponent
xF())/fp_log2(base);}
yP1
ConstantFolding_PowOperations(iM3(tree.GetOpcode()==cPow);nP&&xW
1).lV1
const_value=t33
lR,xW
i8);nU
const_value)i1
t23
if(eI1
lJ3
xW
i8
nH2
tree.eF2
0)yQ2
nP&&lJ3
lR
nH2
nU
1)i1
t23
nP&&xW
1)nC==cMul){bool
y12=false
iK2
lW2=lR
tX
mulgroup=xW
1
iY1
mulgroup
iY
mulgroup
l8
a).lV1
imm=mulgroup
l8
a)x41;{if(x91
lW2,imm))break
iK2
lX2=t33
lW2,imm);lG3
lX2,xG1)break;if(!y12){y12=true;cA1
lD1}
lW2=lX2;cA1
i91
a
e02}
if(y12){cA1
e33);
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Before pow-mul change: "
cR
#endif
xW
0).Become(eA1
lW2));xW
1).Become
eH2);
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"After pow-mul change: "
cR
#endif
}
}
if(eI1
c93==cMul)l14
lY2=xW
i8
iK2
y22=1.0;bool
y12=false
tX&mulgroup=xW
0
iY1
mulgroup
iY
mulgroup
l8
a).lV1
imm=mulgroup
l8
a)x41;{if(x91
imm,lY2))break
iK2
eW1=t33
imm,lY2);lG3
eW1,xG1)break;if(!y12){y12=true;cA1
lD1}
y22*=eW1;cA1
i91
a
e02}
if(y12){cA1
e33)tX
cZ3;cZ3
iH
cPow);cZ3
iF1
tree.lJ2));cZ3.yC2
yB
eL3
cMul
c81
cZ3
yB
AddParam(eA1
y22)yQ2}
if(xW
0)i12
eI1
xW
0)l8
1).lV1
a=xW
0)l8
i8
iK2
b=xW
i8
iK2
c=a*b;if(isEvenInteger(a)&&!isEvenInteger(c)nQ
lK3;lK3
iH
cAbs);lK3.nJ
0)c43
lK3.e33
yB
nB1
0,lK3);}
else
tree.SetParam(0,xW
0)l8
0)xT1
1,eA1
c));eE3
t23}
l33{using
l33
FUNCTIONPARSERTYPES;using
t5;e72
l5{enum
eJ2{MakeFalse=0,MakeTrue=1,t62=2,lN3=3,MakeNotNotP0=4,MakeNotNotP1=5,MakeNotP0=6,MakeNotP1=7,xJ=8}
;enum
lZ2{Never=0,Eq0=1,Eq1=2,yB3=3,yC3=4}
;eJ2
if_identical;eJ2
n02
4];e72{eJ2
what:4;lZ2
when:4;}
l02,l12,l22,l32
yO1
eJ2
Analyze
iR1
xC3
eX1)const{if(a
xI
b
y03
if_identical;yD3
tY
a);yD3
p1=CalculateResultBoundaries(b);if(p0
e61&&p1
yI){if(p0
nL3<p1
yM&&n02
0]iC
0];if(p0
nL3<=p1
yM&&n02
1]iC
1];}
if
cN3
p1
e61){if(p0
yM>p1
nL3&&n02
2]iC
2];if(p0
yM>=p1
nL3&&n02
3]iC
3];}
if(IsLogicalValue(a)){if(l02
nN3
l02.when,p1
y03
l02.what;if(l22
nN3
l22.when,p1
y03
l22.what;}
if(IsLogicalValue(b)){if(l12
nN3
l12.when,p0
y03
l12.what;if(l32
nN3
l32.when,p0
y03
l32.what;eE3
xJ;}
cB1
bool
TestCase(lZ2
when,const
yD3&p){if(!p
yI||!p
e61
cQ
e23
when){case
Eq0:nO3==e62
0.0)t43==p
yM
t83
Eq1:nO3==e62
1.0)t43==p
nL3
t83
yB3:nO3>xH1
t43<=e62
1)t83
yC3:nO3>=xH1
l61
1);yF3;eE3
t23}
;l33
RangeComparisonsData{static
const
l5
Data[6]={{l5
lL3
i3
xJ,l5::i3
xJ
lF1
Eq1
nT1
Eq1
nU1
Eq0
nV1
Eq0}
}
,{l5::x42
lM3
xJ,l5
lM3
xJ
lF1
Eq0
nT1
Eq0
nU1
Eq1
nV1
Eq1}
}
,{l5::x42
lM3
t62,l5::i3
MakeFalse
nU1
yB3
nT1
yC3
yY,{l5
lL3
xJ,l5
lM3
i3
lN3
nU1
yC3
nT1
yB3
yY,{l5::x42::i3
i3
MakeTrue,l5::t62
lF1
yC3
nV1
yB3
yY,{l5
lL3
i3
lN3,l5::xJ,l5
nC1
lF1
yB3
nV1
yC3
yY}
;}
yP1
ConstantFolding_Comparison(eR{using
l33
RangeComparisonsData;assert(tree.GetOpcode()>=cEqual&&tree.GetOpcode()<=cGreaterOrEq);e23
Data[t72-cEqual].Analyze(xW
0),xW
1))){case
l5::MakeFalse:nU
0);nZ
l5
nC1:nU
1
nY3
lN3:tD2
cEqual
nY3
t62:tD2
i51
nY3
MakeNotNotP0:tD2
cNotNot
yB
i91
1
nY3
MakeNotNotP1:tD2
cNotNot
yB
i91
0
nY3
MakeNotP0:tD2
cNot
yB
i91
1
nY3
MakeNotP1:tD2
cNot
yB
i91
0
nY3
xJ:;}
if(xW
1)tD1)e23
c93){case
cAsin:lM
fp_sin(xW
iP2
cAcos:lM
fp_cos(xW
i8))yB
eL3
t72==cLess?cGreater:t72==cLessOrEq?cGreaterOrEq:t72==cGreater?cLess:t72==cGreaterOrEq?cLessOrEq:t72);nZ
cAtan:lM
fp_tan(xW
iP2
cLog:lM
fp_exp(xW
iP2
cSinh:lM
fp_asinh(xW
iP2
cTanh:if(fp_less(fp_abs(xW
i8)nH2
lM
fp_atanh(xW
i8))yQ2
break;yF3
xY3
return
t23}
#include <list>
#include <algorithm>
#ifdef FP_SUPPORT_OPTIMIZER
using
l33
FUNCTIONPARSERTYPES;l33{
#ifdef DEBUG_SUBSTITUTIONS
yE
double
d){union{double
d;uint_least64_t
h
c42
d=d;lR1
h
nX1
#ifdef FP_SUPPORT_FLOAT_TYPE
yE
float
f){union{float
f;uint_least32_t
h
c42
f=f;lR1
h
nX1
#endif
#ifdef FP_SUPPORT_LONG_DOUBLE_TYPE
yE
long
double
ld){union{long
double
ld;e72{uint_least64_t
a;x83
short
b;}
s
c42
ld=ld;lR1
s.b<<data.s.a
nX1
#endif
#ifdef FP_SUPPORT_LONG_INT_TYPE
yE
long
ld){o<<"("
<<std::hex<<ld
nX1
#endif
#endif
}
t5{lN
nE)){}
lN
const
Value_t&i
y8
xD3
nE
i
x52
#ifdef __GXX_EXPERIMENTAL_CXX0X__
lN
Value_t&&i
y8
xD3
nE
tF2
i)x52
#endif
lN
x83
v
y8
VarTag
nE
iU2,v
x52
lN
iU1
o
y8
OpcodeTag
nE
o
x52
lN
iU1
o,x83
f
y8
FuncOpcodeTag
nE
o,f
x52
lN
const
eX1
y8
CloneTag
nE*b.data)){}
tK1
yZ2::~c02(){}
lB
ReplaceWithImmed(tX1{
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Replacing "
iL2*this);if(IsImmed())OutFloatHex(cV2,GetImmed()lE2" with const value "
<<i;OutFloatHex(cV2,i
lE2"\n"
;
#endif
data=new
xK2
xF(i);}
tK1
e72
ParamComparer{iD2()iR1
xC3
eX1)const{if(a
nP2!=b
nP2)return
a
nP2<b
nP2
i1
a.GetHash()<b.GetHash();}
}
;xL1
xK2
xF::Sort(yY3
Opcode){case
cAdd:case
cMul:case
cMin:case
cMax:case
cAnd:case
cAbsAnd:case
cOr:case
cAbsOr:case
cHypot:case
cEqual:case
i51:std::sort(iR2
iJ2
iR2
end(),ParamComparer
xF());lC
cLess
lY
cGreater;}
lC
cLessOrEq
lY
cGreaterOrEq;}
lC
cGreater
lY
cLess;}
lC
cGreaterOrEq
lY
cLessOrEq;}
break;yF3
xY3}
lB
AddParam
iR1
param){y1
c52
param);}
lB
AddParamMove(yZ2&param){y1
c52
yZ2());y1.back().swap(param);}
lB
SetParam
iZ1
which,const
eX1)nW1
which
iQ2
y1[which]=b;}
lB
nB1
size_t
which,eX1)nW1
which
iQ2
y1[which
tQ3
b);}
lB
AddParams
iS1
nK){y1.insert(y1.end(),n12.iJ2
n12.end());}
lB
AddParamsMove(nK){size_t
endpos=y1
eJ3,added=n12
eJ3;y1
xF3
endpos+added,yZ2())eK3
p=0;p<added;++p)y1[endpos+p
tQ3
n12[p]);}
lB
AddParamsMove(nK,size_t
n22)nW1
n22
iQ2
i91
n22);AddParamsMove(tO1}
lB
SetParams
iS1
nK){eK
tmp(tO1
y1.swap(tmp);}
lB
SetParamsMove(nK){y1.swap(tO1
n12.clear();}
#ifdef __GXX_EXPERIMENTAL_CXX0X__
lB
SetParams(eK&&n12){SetParamsMove(tO1}
#endif
lB
i91
size_t
index){eK&Params=y1;
#ifdef __GXX_EXPERIMENTAL_CXX0X__
iR2
erase(iR2
begin()+index);
#else
t63
index].data=0
eK3
p=index;p+1<iS2;++p)t63
p].data.UnsafeSetP(&*t63
p+1
iQ2
t63
iS2-1].data.UnsafeSetP(0);iR2
resize(iS2-1);
#endif
}
lB
DelParams(){y1.clear();}
yP1
yZ2::IsIdenticalTo
iS1
eX1)const{if(&*data==&*b.data)return
true
i1
data->IsIdenticalTo(*b.data);}
yP1
xK2
xF::IsIdenticalTo
iS1
xK2
xF&b)const{if(Hash!=b.Hash
cQ
if(Opcode!=b.Opcode
cQ
e23
Opcode){case
cImmed:return
lJ3
Value,b.Value)t83
iU2:return
lL2==b.lK2
case
cFCall:case
cPCall:if(lL2!=b.lL2
cQ
break;yF3
xY3
if(iS2!=b.iS2
cQ
for
iZ1
a=0;a<iS2;++a){if(!iT2
xI
b.iT2)cQ}
lD2}
lB
Become
iS1
eX1){if(&b!=this&&&*data!=&*b.data){DataP
tmp=b.data;lD1
data.swap(tmp);}
}
lB
CopyOnWrite(){if(GetRefCount()>1)data=new
xK2
xF(*data);}
tK1
yZ2
yZ2::GetUniqueRef(){if(GetRefCount()>1)return
yZ2(*this,CloneTag())i1*this;}
i4):yS
cNop
iR3),n8
i4
const
xK2&b):yS
b.Opcode
iR3
b.Value),lL2(b.cO1,t53
b.Params),Hash(b.Hash),Depth(b.Depth
eB1
b.lM2){}
i4
tX1:yS
cImmed
iR3
i),n8
#ifdef __GXX_EXPERIMENTAL_CXX0X__
i4
xK2
xF&&b):yS
b.Opcode
iR3
tF2
b.Value)),lL2(b.cO1,t53
tF2
b.Params)),Hash(b.Hash),Depth(b.Depth
eB1
b.lM2){}
i4
Value_t&&i):yS
cImmed
iR3
tF2
i)),n8
#endif
i4
iU1
o):yS
o
iR3),n8
i4
iU1
o,x83
f):yS
o
iR3),lL2(f),t53),Hash(),Depth(1
eB1
0){}
}
#endif
#ifdef FP_SUPPORT_OPTIMIZER
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <iostream>
using
l33
FUNCTIONPARSERTYPES;
#ifdef FUNCTIONPARSER_SUPPORT_DEBUGGING
l33{xL1
tZ1
nO,std
c9&done,std::ostream&o){x51
tZ1
xW
a),done,o);std::ostringstream
buf
iL2
tree,buf);done[nJ2].insert(buf.str());}
}
#endif
t5{
#ifdef FUNCTIONPARSER_SUPPORT_DEBUGGING
xL1
DumpHashes(cE){std
c9
done;tZ1
tree,done,o);for(std
c9::const_iterator
i=done.y73
i!=done.end();++i){const
std::set<eM3>&flist=i
eC2;if(flist
eJ3!=1)o<<"ERROR - HASH COLLISION?\n"
;for(std::set<eM3>::const_iterator
j=flist.y73
j!=flist.end();++j){o<<'['<<std::hex<<i->first.hash1<<','<<i->first.hash2<<']'<<std::dec;o<<": "
<<*j<<"\n"
;}
}
}
xL1
DumpTree(cE){e32
iF3;e23
t72){case
cImmed:o<<tree
x41
t73
iU2:o<<"Var"
<<(tree.GetVar()-iU2)t73
cAdd:iF3"+"
;lC
cMul:iF3"*"
;lC
cAnd:iF3"&"
;lC
cOr:iF3"|"
;lC
cPow:iF3"^"
;break;yF3
iF3;o<<FP_GetOpcodeName(t72);cZ2
cFCall||t72==cPCall)o<<':'<<tree.GetFuncNo();}
o<<'(';if
l51<=1&&sep2[1])o<<(sep2+1)<<' ';x51{if(a>0)o<<' '
iL2
xW
a),o);if(a+1<tree.GetParamCount())o<<sep2;}
o<<')';}
xL1
DumpTreeWithIndent(cE,const
eM3&indent){o<<'['<<std::hex<<(void*)(&tree.lJ2))<<std::dec<<','<<tree.GetRefCount()<<']';o<<indent<<'_';e23
t72){case
cImmed:o<<"cImmed "
<<tree
x41;o<<'\n'
t73
iU2:o<<"VarBegin "
<<(tree.GetVar()-iU2);o<<'\n'
i1;yF3
o<<FP_GetOpcodeName(t72);cZ2
cFCall||t72==cPCall)o<<':'<<tree.GetFuncNo();o<<'\n';}
x51{eM3
ind=indent
eK3
p=0;p<ind
eJ3;p+=2)if(ind[p]=='\\')ind[p]=' ';ind+=(a+1<tree.GetParamCount())?" |"
:" \\"
;DumpTreeWithIndent(xW
a),o,ind);}
o<<std::flush;}
#endif
}
#endif
using
l33
lA1;using
l33
FUNCTIONPARSERTYPES;
#include <cctype>
l33
lA1{x83
ParamSpec_GetDepCode
iS1
eA2&b
yY3
b.first){case
ParamHolder:{cM*s=(cM*)b.second
i1
s->depcode;}
case
SubFunction:{cN*s=(cN*)b.second
i1
s->depcode;}
yF3
xY3
return
0;}
xL1
DumpParam
iS1
eA2&yA2
std::ostream&o){static
const
char
ParamHolderNames[][2]={"%"
,"&"
,"x"
,"y"
,"z"
,"a"
,"b"
,"c"
}
;x83
y32
0;e23
lX3.first){case
NumConstant:{const
ParamSpec_NumConstant
xF&param=*iS1
ParamSpec_NumConstant
xF*tF1;using
l33
FUNCTIONPARSERTYPES;o.precision(12);o<<param.constvalue;xY3
case
ParamHolder:{cM&yU3
cM*tF1;o<<ParamHolderNames[param.index];y32
param.constraints;xY3
case
SubFunction:{cN&yU3
cN*tF1;y32
param.constraints;yF
GroupFunction){if
yZ3
lG1==cNeg){o<<"-"
;n2}
iP1
param.lG1==cInv){o<<"/"
;n2}
else{eM3
opcode=FP_GetOpcodeName((iU1)param.lG1).substr(1
iY1
0;a<opcode
eJ3;++a)opcode[a]=(char)std::toupper(opcode[a]);o<<opcode<<"( "
;n2
o<<" )"
;}
}
else{o<<'('<<FP_GetOpcodeName((iU1)param.lG1)<<' ';yF
PositionalParams)o<<'[';yF
SelectedParams)o<<'{';n2
if
yZ3
data.n1!=0)o<<" <"
<<iH3.n1<<'>';yF
PositionalParams)o<<"]"
;yF
SelectedParams)o<<"}"
;o<<')';}
xY3
c73(ImmedConstraint_Value(constraints&ValueMask)){case
ValueMask:lC
Value_AnyNum:lC
x62:o<<"@E"
;lC
Value_OddInt:o<<"@O"
;lC
i11:o<<"@I"
;lC
Value_NonInteger:o<<"@F"
;lC
eY1:o<<"@L"
;yV3
ImmedConstraint_Sign(constraints&SignMask)){case
SignMask:lC
Sign_AnySign:lC
nD1:o<<"@P"
;lC
eZ1:o<<"@N"
;yV3
ImmedConstraint_Oneness(constraints&OnenessMask)){case
OnenessMask:lC
Oneness_Any:lC
Oneness_One:o<<"@1"
;lC
Oneness_NotOne:o<<"@M"
;yV3
ImmedConstraint_Constness(constraints&ConstnessMask)){case
ConstnessMask:lC
i01:if(lX3.first==ParamHolder){cM&yU3
cM*tF1;if
yZ3
index<2)xY3
o<<"@C"
;lC
Constness_NotConst:o<<"@V"
;lC
Oneness_Any:xY3}
xL1
DumpParams
lT1
paramlist,x83
count,std::ostream&o){for
lT1
a=0;a<count;++a){if(a>0)o<<' ';const
eA2&param=ParamSpec_Extract
xF(paramlist,a);DumpParam
xF(param,o);x83
depcode=ParamSpec_GetDepCode(param);if(depcode!=0)o<<"@D"
<<depcode;}
}
}
#include <algorithm>
using
l33
lA1;using
l33
FUNCTIONPARSERTYPES;l33{cM
plist_p[37]={{2,0,0x0}
nT
0,0x4}
nT
nD1,0x0}
nT
eZ1|Constness_NotConst,0x0}
nT
Sign_NoIdea,0x0}
nT
eY1,0x0}
,{3,Sign_NoIdea,0x0}
,{3,0,0x0}
,{3,eY1,0x0}
,{3,0,0x8}
,{3,Value_OddInt,0x0}
,{3,Value_NonInteger,0x0}
,{3,x62,0x0}
,{3,nD1,0x0}
,{0,eZ1|lV{0,lV{0,nD1|lV{0,x62|lV{0,i01,0x1}
,{0,i11|nD1|lV{0,i21
i01,0x1}
,{0,i21
lV{0,Oneness_One|lV{0,eY1|lV{1,lV{1,x62|lV{1,i21
lV{1,i11|lV{1,nD1|lV{1,eZ1|lV{6,0,0x0}
,{4,0,0x0}
,{4,i11,0x0}
,{4,lV{4,0,0x16}
,{5,0,0x0}
,{5,lV}
yO1
e72
plist_n_container{static
const
ParamSpec_NumConstant
xF
plist_n[20];}
yO1
const
ParamSpec_NumConstant
xF
plist_n_container
xF::plist_n[20]={{e62-2
i5-1
i5-0.5
i5-0.25
i5
0
tG2
fp_const_deg_to_rad
xF(tG2
fp_const_einv
xF(tG2
fp_const_log10inv
xF(i5
0.5
tG2
fp_const_log2
xF(i5
1
tG2
fp_const_log2inv
xF(i5
2
tG2
fp_const_log10
xF(tG2
fp_const_e
xF(tG2
fp_const_rad_to_deg
xF(tG2-fp_const_pihalf
xF(),xU1{xH1,xU1{fp_const_pihalf
xF(),xU1{fp_const_pi
xF(),xU1}
;cN
plist_s[517]={{{1,15,tH2
398,tH2
477,tH2
15,cNeg,GroupFunction,0}
,i01,0x1
lR3
15,y42
24,y42
465,y42
466,y42
498,cInv,lT
2,327995
x9
l0
2,48276
x9
l6
260151
x9
l6
470171
x9
l6
169126
x9
l6
48418
x9
l6
1328
x9
l6
283962
x9
l6
169275
x9
l6
39202
x9
l6
283964
x9
l6
283973
x9
l6
476619
x9
l6
296998
x9
l6
47
x9
SelectedParams,0}
,0,0x4
nH
161839
x9
l6
25036
x9
l6
35847
x9
l6
60440
x9
l6
30751
x9
l6
270599
x9
l6
60431
x9
l6
259119
x9
l6
183474
x9
l6
332066
x9
l6
7168
x9
l6
197632
x9
l6
291840
x9
l6
283648
x9
l6
238866
x9
l6
239902
x9
l6
31751
x9
l6
244743
x9
l6
384022
x9
SelectedParams,0}
,0,0x4
nH
385262
x9
l6
386086
x9
l6
393254
x9
SelectedParams,0}
,0,0x5
nH
393254
x9
l6
386095
x9
l6
387312
x9
l6
18662
x9
l6
61670
x9
l6
387397
x9
l6
247855
x9
SelectedParams,0}
,0,0x1
nH
342063
x9
l6
297007
x9
l6
15820
x9
l6
393263
x9
l6
393263
x9
SelectedParams,0}
,0,0x5
nH
161847
x9
l6
258103
x9
l6
249073
x9
l6
249076
x9
iO
0,0
x9
nF
0,0
i31
1,45
x9
nF
1,53
x9
nF
1,54
x9
nF
1,55
x9
nF
1,56
x9
nF
1,26
x9
nF
1,259
eK2
0x16
lR3
253
x9
nF
1,272
i31
1,323
eK2
0x16
lR3
0
x9
nF
1,21
x9
nF
1,447
eK2
0x4
lR3
449
eK2
0x4
lR3
0
eK2
0x4
lR3
0
tJ
2}
,0,0x4
lR3
15
x9
nF
1,24
tJ
2}
,0,0x0
nH
58392
i31
0,0
tJ
1}
,nD1,0x0
nH
24591
lS3
33807
lS3
48143
lS3
285720
lS3
290840
lS3
305152,l9
312400,l9
39202,l9
121894,l9
421926,l9
429094,l9
443430,l9
317834,l9
329098,l9
7633,l9
7706,l9
7730,l9
38,l9
50587,l9
406528,l9
24583,l9
31751,l9
405511,l9
321551
iV2
327713,l9
322596,l9
88361,l9
335174,l9
327050,l9
493606,l9
496678,l9
503846,l9
516134,l9
7217,l9
333875,l9
336896,l9
524326,l9
509952,l9
286727,l9
90127,l9
131087,l9
296976,tQ1
324623,l1
0x14
nH
332815,l1
0x10}
,{{3,7340056,tQ1
289092,l9
92176
iV2
337935
e31
7340060
lO3
7340176,l9
338959
e31
7340061
iV2
7206,l9
x63
l9
357414,l9
368678,l9
370745,l1
0x7}
,{{3,7340177,l9
39277,tQ1
426398
lO3
40272286
iV2
490910
lO3
40336798
iV2
50600,l9
426462
iV2
490974
iV2
370726,l1
0x6
nH
371750,l1
0x6
nH
428070
e31
40336862
iV2
38378,l9
50671
e31
47662080,l9
477184,l9
568320,l9
371727,l1
0x7}
,{{3,15779306,l9
370703,l1
0x7
nH
39277,l9
39279,l1
0x4}
,{{3,15779238,l9
39338,tQ1
436262,l9
508966,l9
39409,tQ1
296998,tQ1
35847,l9
15,tQ1
377894,l9
386063,l1
0x1
nH
15,l9
7192,l9
122904,l9
121880,l9
30751,l9
57,l9
7456,l9
15674
e31
67579935,l9
39237,l9
58768,l9
62924,l9
121856,l9
15760
e31
64009216,l1
0x0}
,{{0,0,xL
0,0,iW
2,eC1
2,eD1
3,eC1
3,eD1
38,xL
1,38,iW
14,xL
1,57,xL
1,16,eL2
0x0
nH
471103,eL2
0x1
lR3
303,xL
1,323,yH3
0x0
nH
471363,eL2
0x16
lR3
293,eC1
294,eD1
295,xL
1,296,iW
400,xL
1,0,xL
1,460,xL
1,465,xL
1,16,eL2
0x1
lR3
57,yH3
0x1
lR3
0,iW
21,xL
1,15,eL2
0x0
nH
24591,xL
1,24,iW
517,yH3
0x0
nH
46095,lK
46104,lK
15397,lK
287789,lK
66584,lK
404763,lK
62504,lK
15409,lK
39951,lK
24591,lK
33807,lK
50200,lK
62509,lK
50176,lF,178176,t21
tF3
283648,lF,19456,lF,27648,lF,89088,lF,86016,lF,488448,lF,14342,lF,58375,lF,46147
xX
46151,lF,284679,lF,7183,lF,46159
xX
38993
xX
50265,lF,50249,lF,283808,lF,284835,lF,24822,lF,10240,lF,11264,lF,7170,lF,x63
lF,17408,lF,164864,lF,237568,lF,242688,t21
0x14
nH
476160,lF,25607,lF,121871,lF,50252,lF,39374,lF,50183,lF,7192,lF,121887,lF,252979,lF,46155,lF,38919,lF,50267,lF,50268,lF,50253,lF,46190,lF,50295,lF,7563,t21
0x10
nH
416811,lF,416819,lF,40046,lF,46191
xX
415795,lF,40047
xX
415787,lF,39015,t21
0x5
nH
39326
xX
39326,lF,39332,t21
0x5
nH
39333
cC2
50590
xX
50590,lF,39338
xX
39338,lF,39335,t21
0x5
nH
15786
xX
146858,lF,39372,lF,39379,lF,39380,lF,39390
xX
50654
xX
50654,lF,24,t21
0x6
nH
62,lF,24,lF,62,t21
0x6
nH
43,lF,43
xX
51,lF,51
xX
50269,lF,50176
xX
50270,lF,39159,lF,39183
xX
7168
xX
31744,lF,99328,lF,31746,lF,100376,lF,39409
xX
39411
xX
39411,lF,39420,lF,39420
xX
15,lF,39025,t21
0x5
nH
39422,lF,16384,lF,62853,lF,15360,lF,15
cC2
16,lF,7183
cC2
7172
tW2
y71,nD1,0x0
nH
24591
tW2
lT
2,50200
tW2
lT
2,63521
tW2
lT
2,62500
tW2
lT
2,50453
tW2
lT
2,62488
tW2
lT
1,0,t93
7,t93
194,t93
0,cAcos
tA3
cAcosh
tA3
cAsin
tA3
cAsinh
nS
119,cAsinh
tA3
cAtan
t11
306176,cAtan2
t11
x63
cAtan2
tA3
cAtanh
nS
246,cCeil
tA3
cCeil
tB3
0,cD2
0,cCos
tB3
7,cD2
91,cD2
92,cD2
119,cD2
236,cD2
255,cD2
214,iW2
236,iW2
464,iW2
0,cCosh
tB3
0,iW2
0,cExp
nS
7,cExp
nS
91,cExp
tA3
yI3
7,yI3
91,yI3
246,cFloor
tA3
cFloor,lA
0x4
nH
309540,cHypot
t11
316708,cHypot
t11
316724,cHypot,l0
3,32513024,eM2
34627584
iL
31493120,eM2
89213952
iL
149042176
iL
246647808
iL
301234176
iL
494360576
iL
498558976
iL
62933520
iL
62933520,eM2
62933526
iL
62933526,eM2
24670208
iL
579378176
iL
573578240
iL
32513024
iL
566254592
iL
7900160
iL
588822528,cIf
nS
119,cInt
nS
246,tI2
0,tI2
7,tI2
31,tI2
194,tI2
363,tI2
15,cLog,lT
1,24,cLog,lT
1,0,cLog10
tA3
cLog2
t11
x63
cMax
t11
35847,cMax
t11
30751,cMax
tA3
cMax,AnyParams,1}
,0,0x4
nH
x63
cMin
t11
35847,cMin
t11
30751,cMin
tA3
cMin,AnyParams,1}
,0,0x4
nH
24591,cMin,lT
1,0,x72
7,x72
91,x72
92,x72
119,x72
149,x72
231,cSin,lA
0x5
lR3
246,x72
255,x72
254,x72
0,cSin
tB3
273,cSin,lA
0x1
lR3
214,y52
231,tD3
lA
0x5
lR3
246,y52
254,y52
255,y52
464,y52
0,cSinh
tB3
0,y52
15,cSqrt,lT
1,0,cTan
tA3
cTan
tB3
115,cTan
tB3
116
tC3
231
tC3
246
tC3
273
tC3
254
tC3
255,cTan
tA3
y62
0,cTanh
tB3
213,y62
231,y62
246,y62
254,y62
255,y62
0,cTrunc
t11
15384,cSub,lT
2,15384,cDiv,lT
2,476626,cDiv,lT
2,121913,tJ2
x63
lP3
tF3
x63
tJ2
31744,lP3
0x20
nH
31751,lP3
0x24
nH
31751,tJ2
121913,i51
t11
x63
cLess,lA
tF3
41984,cLess,lA
0x4
nH
41984,cLess
t11
7,cLess
t11
x63
cLessOrEq
t11
296182,cLessOrEq
t11
7168
tV2,lA
tF3
41984
tV2,lA
0x4
nH
41984
tV2
t11
7
tV2
t11
x63
y9
l0
2,296182,cGreaterOrEq
tA3
n32
245,n32
7,n32
550,n32
553,n32
554,n32
556,n32
31,n32
559,n32
15,n32
560,cNot
t11
7706,lT3
x63
lT3
35847,lT3
30751,lT3
463903,lT3
466975,cAnd,iO
0,0,cAnd,nF
2,x63
e03
7706,e03
35847,e03
463903,e03
466975,e03
30751,cOr,iO
1,0,n42
91,n42
131,n42
245,n42
215,n42
246,cDeg
nS
246,cRad
t11
x63
cAbsAnd,l6
x63
cAbsOr,iO
1,0,cC3
tA3
cAbsNotNot,l0
3,32513024,yT3
lA
0x0}
,}
;}
l33
lA1{const
Rule
grammar_rules[262]={{ProduceNewTree,17,1,0,{1,0,cAbs,eN2
409,{1,146,cAtan,eN2
403
nT
1324,cAtan2,eN2
405
nT
307201,cAtan2
eL
253174
nT
255224,cAtan2
eL
259324
nT
257274,cAtan2,eN2
152,{1,252,cCeil
i7
486,{1,68
yH2
482,{1,122
yH2
483,{1,124
yH2
151,{1,125
yH2
419,{1,123
yH2
0,{1,403,cCos,l2
2,1,246,{1,252,cCos,l2
18,1,0,{1,400
yH2
301,{1,406,cCosh,l2
2,1,246,{1,252,cCosh,l2
18,1,0,{1,400,cCosh
i7
458,{1,121,cFloor,eN2
150,{1,252,cFloor,tG3
156,{3,7382016,eF
549,{3,8430592,eF
556,{3,8436736,eF
157,{3,42998784,eF
550,{3,42999808,eF
562,{3,43039744,eF
557,{3,49291264,eF
538,{3,49325056,eF
469,{3,1058318,eF
473,{3,1058324,eF
473,{3,9438734,eF
469,{3,9438740,cIf,l2
0,3,32542225,{3,36732434,cIf,l2
0,3,32542231,{3,36732440,cIf,yR3
573,{3,32513026,cIf,yR3
515,{3,455505423,cIf,yR3
515,{3,433506837,cIf
i7
78,{1,256,cLog
i7
69,{1,258,cLog
i7
404,{1,72,cLog
i7
159,{1,147,cLog,l2
0,1,0
nT
487425,cMax
l3
16,1,445
nT
yJ3
cMax
l3
0,1,0
nT
483329,cMin
l3
16,1,446
nT
yJ3
cMin,c3
0,1,153
nT
24832
tW2
tG3
153
nT
25854
tW2
tG3
154
nT
129039
tW2
xV1
32055
tW2
xV1
32056
tW2
xV1
32057
tW2
l2
0,2,166288
nT
32137
tW2
xV1
33082
tW2
l2
0,2,7168
nT
12688
tW2
l2
0,2,7434
nT
12553,tX2
435
nT
46146,tX2
436
nT
46154,tX2
437
nT
46150,tX2
169
nT
83983,tX2
168
nT
130082,tX2
175
nT
133154
tW2
tI3
476160
nT
471055
tW2
tI3
274432
nT
273423
tW2
tI3
251904
nT
266274
tW2
tI3
251904
nT
263186,tX2
171,{1,252,cE2
421,{1,68,cE2
151,{1,122,cE2
419,{1,124,cE2
170,{1,125,cE2
482,{1,123,cE2
0,{1,405,cE2
172,{1,252,cSinh
i7
328,{1,404,cSinh
i7
173,{1,252,tJ3
0,{1,408,tJ3
176,{1,410,tJ3
177,{1,252,cTanh,l2
0,1,442
nT
449551,i6
1,441
nT
yJ3
i6
1,167
nT
268549,i6
1,181
nT
276749,i6
1,180
nT
276500,i6
2,190770
nT
189622,i6
2,194748
nT
193723,i6
2,202943
nT
196795,i6
2,59699
nT
298148,i6
2,59714
nT
325815,i6
2,59724
nT
343224
x9
c3
2,1,337,{1,333
tJ
1
tF
336,{1,338
tJ
1}
}
,{ReplaceParams,2,1,340
nT
1363
nR
342
nT
1365
nR
463
nT
472524
nR
47
nT
356711
nR
349
nT
200751
nR
360
nT
199727
nR
480
nT
207053
nR
481
nT
208077
nR
417
nT
211144
nR
209
nT
211145
nR
418
nT
215240
nR
212
nT
212329
nR
204
nT
373097
nR
211
nT
372944
nR
217
nT
201944
nR
221
nT
223448
nR
367
nT
508329
nR
219
nT
508126
nR
224
nT
225705
nR
223
nT
225776
nR
365
nT
230825
nR
426
nT
377057
nR
497
nT
377054
nR
497
nT
204201
nR
426
nT
375280
nR
224
nT
375006,cAdd
l3
2,2,407781
nT
233698,cAdd
l3
2,2,59763
nT
233842,i6
1,372
nT
1397,lW1
95
nT
24705,lW1
96
nT
24708,lW1
444
nT
449551,lW1
443
nT
yJ3
lW1
100
nT
101750,lW1
108
nT
106821,lW1
105
nT
103749
lU3
0,2,110607
nT
108869
lU3
0,2,107535
nT
109893,lJ
0
tF
112
nT
111634,cMul,SelectedParams,0
tF
567,{1,52,lJ
1
tF
568,{1,42,lJ
1}
}
,{ReplaceParams,2,1,467
nT
45516
xA
356
nT
51555
xA
468
nT
49612
xA
357
nT
47459
xA
429
nT
438699
xA
432
nT
441774
xA
486
nT
498726
xA
494
nT
504870
xA
382
nT
435579
xA
497
nT
435709
xA
426
nT
508287
xA
414
nT
500092
xA
499
nT
352744
xA
345
nT
367092
xA
381
nT
425318
xA
478
nT
425460
xA
47
nT
512501
xA
505
nT
355817
xA
47
nT
516598
xA
507
nT
518182
xA
508
nT
358896
xA
351
nT
388605
xA
511
nT
360939
xA
503
nT
354788
xA
514
nT
525350
xA
510
nT
394342
xA
386
nT
351346
lU3
2,2,363004
nT
361968
lU3
16,1,117
nT
1157
lU3
16,1,118
nT
1158
lU3
16,1,402
nT
411024
lU3
16,2,58768
nT
1472
lU3
16,2,15760
nT
1474
lU3
17,1,0,{1,400
lU3
17,1,57,{1,14,lJ
0}
}
,{ProduceNewTree,4,1,538
nT
41,lQ3
yK3
0
nT
5167,lQ3
cH
41984
e22
lQ3
cH
tU
lQ3
cH
eV
lQ3
cH
eW
cEqual
cN1
24849,cEqual
eL
tV
cEqual
eL
n52
281873,cEqual
eL
iP
cEqual
eL
lH1
lQ3
yK3
562
nT
41,i51,yK3
538
nT
5167,i51,cH
41984
e22
i51,cH
tU
i51,cH
eV
i51,cH
eW
i51
cN1
24849,i51
eL
tV
i51
eL
n52
281873,i51
eL
iP
i51
eL
lH1
i51,cH
tU
yN3
eV
yN3
eW
cLess,eN2
571
nT
46080,cLess
cN1
24832,cLess
eL
xW1
cLess
eL
tV
cLess
eL
n52
tK3
cLess
eL
nY1
cLess
eL
iP
cLess
eL
lH1
cLess,yL3
562
e22
yN3
tU
n62
cH
eV
n62
cH
eW
n62
eN2
565
nT
409615,cLessOrEq
cN1
24832,cLessOrEq
eL
xW1
cLessOrEq
eL
tV
cLessOrEq
eL
n52
tK3
cLessOrEq
eL
nY1
cLessOrEq
eL
iP
cLessOrEq
eL
lH1
n62
yL3
562
nT
409647,n62
cH
tU
cF2
eV
cF2
eW
cGreater,eN2
539
nT
409615
tV2
cN1
24832
tV2
eL
xW1
cGreater
eL
tV
cGreater
eL
n52
281856
tV2
eL
nY1
cGreater
eL
iP
cGreater
eL
lH1
cGreater,yL3
538
nT
409647,cF2
tU
y9
cH
eV
y9
cH
eW
y9
eN2
572
nT
46080,y9
nQ2
529654
nT
24832,y9
nQ2
xW1
y9
nQ2
tV
y9
nQ2
n52
tK3
y9
nQ2
nY1
y9
nQ2
iP
y9
nQ2
lH1
y9
yL3
538
e22
y9
yK3
519,{1,137,cNot,yR3
571,{1,2,cNot,l2
0,1,452
nT
yJ3
lV3
0,2,537097,{3,547892744,cAnd,c3
16,1,566,{1,5,cAnd,AnyParams,1}
}
,{ReplaceParams,16,1,569
nT
13314,lV3
16,1,544
nT
553498,lV3
16,1,546
nT
462369,lV3
16,1,548
nT
466465,lV3
0,1,457
nT
yJ3
xX1
570
nT
13314,xX1
563
nT
8197,xX1
541
nT
553498,xX1
542
nT
462369,xX1
543
nT
466465,xX1
564
nT
143365,cOr,c3
4,1,525,{1,137,yS3
yR3
572,{1,2,yS3
l4
17,1,0,{1,0,yS3
eN2
537,{1,256,cAbsNotNot,c3
18,1,531,{1,254,cAbsNotNot,c3
0,1,572,{3,43039744,yT3
tG3
571,{3,49325056,yT3
yR3
454,{3,32513586,yT3
l2
16,3,32542225,{3,36732434,yT3
y71}
,}
;e72
grammar_optimize_abslogical_type{y3
9
cT
grammar_optimize_abslogical_type
grammar_optimize_abslogical={9,{34,192,228,238,242,247,254,260,261}
}
;}
e72
grammar_optimize_ignore_if_sideeffects_type{y3
59
cT
grammar_optimize_ignore_if_sideeffects_type
grammar_optimize_ignore_if_sideeffects={59,{0,20,21,22,23,24,25,26,cO
l42
78,cP
cU
e72
grammar_optimize_nonshortcut_logical_evaluation_type{y3
56
cT
grammar_optimize_nonshortcut_logical_evaluation_type
grammar_optimize_nonshortcut_logical_evaluation={56,{0,25,cO
l42
78,cP
241,243,244,245,246,248,249,250,251,252,253,255,256,257,258,259}
}
;}
e72
grammar_optimize_recreate_type{y3
22
cT
grammar_optimize_recreate_type
grammar_optimize_recreate={22,{18,55,56,57,80,81,82,83,84,85,117,118,120,121,130,131,132,133,134,135,136,137}
}
;}
e72
grammar_optimize_round1_type{y3
125
cT
grammar_optimize_round1_type
grammar_optimize_round1={125,{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,19,25,cO
37,38,l42
45,46,47,48,49,50,51,52,53,54,58,59,60,61,62,63,64,65,66,67,68,69,70,71,78,79,80,81,82,83,84,85,86,87,88,93,94,95,96,97,98,99,100,101,117,118,119,120,121,122,123,124,125,126,127,128,129,138,160,161,162,163,164,165,166,167,168,169,178,179,180,200,204,212,216,224,236,237,239,240,cU
e72
grammar_optimize_round2_type{y3
103
cT
grammar_optimize_round2_type
grammar_optimize_round2={103,{0,15,16,17,25,cO
39,40,l42
45,46,47,48,49,50,51,52,53,54,59,60,72,73,78,79,86,87,88,89,90,91,92,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,119,122,123,124,125,126,127,128,139,159,160,161,162,163,164,165,166,167,168,169,178,179,180,200,204,212,216,224,236,237,239,240,cU
e72
grammar_optimize_round3_type{y3
79
cT
grammar_optimize_round3_type
grammar_optimize_round3={79,{74,75,76,77,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,170,171,172,173,174,175,176,177,181,182,183,184,185,186,187,188,189,190,191,193,194,195,196,197,198,199,201,202,203,205,206,207,208,209,210,211,213,214,215,217,218,219,220,221,222,223,225,226,227,229,230,231,232,233,234,235}
}
;}
e72
grammar_optimize_round4_type{y3
12
cT
grammar_optimize_round4_type
grammar_optimize_round4={12,{18,55,56,57,130,131,132,133,134,135,136,137}
}
;}
e72
grammar_optimize_shortcut_logical_evaluation_type{y3
53
cT
grammar_optimize_shortcut_logical_evaluation_type
grammar_optimize_shortcut_logical_evaluation={53,{0,25,cO
l42
78,cP
cU}
l33
lA1{tK1
eA2
ParamSpec_Extract
lT1
paramlist,lJ1){index=(paramlist>>(index*10))&1023;if(index>=57)return
eA2(SubFunction,cG2
plist_s[index-57]);if(index>=37)return
eA2(NumConstant,cG2
plist_n_container
xF::plist_n[index-37])i1
eA2(ParamHolder,cG2
plist_p[index]);}
}
#ifdef FP_SUPPORT_OPTIMIZER
#include <stdio.h>
#include <algorithm>
#include <map>
#include <sstream>
using
l33
FUNCTIONPARSERTYPES;using
l33
lA1;using
t5;using
nG1;l33{nN1
It,x93
T,x93
Comp>t31
MyEqualRange(It
first,It
last,const
T&val,Comp
comp){size_t
len=last-first;while(len>0){size_t
xR3
len/2;It
x23(first);x23+=half;if(comp(*x23,val)){first=x23;++first;len=len-half-1;}
iP1
comp(val,*x23)){len=half;}
else{It
left(first);{It&eO2=left;It
last2(x23);size_t
len2=last2-eO2;while(len2>0){size_t
half2=len2/2;It
eN3(eO2);eN3+=half2;if(comp(*eN3,val)){eO2=eN3;++eO2;len2=len2-half2-1;}
else
len2=half2;}
}
first+=len;It
right(++x23);{It&eO2=right;It&last2=first;size_t
len2=last2-eO2;while(len2>0){size_t
half2=len2/2;It
eN3(eO2);eN3+=half2;if(comp(val,*eN3))len2=half2;else{eO2=eN3;++eO2;len2=len2-half2-1;}
}
eE3
t31(left,right);}
eE3
t31(first,first);}
tK1
e72
OpcodeRuleCompare{iD2()iS1
nP1
x83
y72)const{const
Rule&rule=grammar_rules[y72]i1
t72<rule
yR2.subfunc_opcode;}
iD2()lT1
y72,const
eR
const{const
Rule&rule=grammar_rules[y72]i1
rule
yR2.subfunc_opcode<t72;}
}
yO1
bool
TestRuleAndApplyIfMatch(t41
nP1
bool
c4{MatchInfo
xF
info;n31
found(false,cZ());if((rule.lI1
LogicalContextOnly)&&!c4{tR1
if(nB
IsIntType
xF::nS3){if(rule.lI1
NotForIntegers)tR1
cJ3
rule.lI1
OnlyForIntegers)tR1
if(nB
IsComplexType
xF::nS3){if(rule.lI1
NotForComplex)tR1
cJ3
rule.lI1
OnlyForComplex)tR1
for(;;){
#ifdef DEBUG_SUBSTITUTIONS
#endif
found=TestParams(rule
yR2
cU3,found.specs,info,true);if(found.found)break;if(!&*found.specs){fail:;
#ifdef DEBUG_SUBSTITUTIONS
DumpMatch
yG2,false);
#endif
return
t23}
#ifdef DEBUG_SUBSTITUTIONS
DumpMatch
yG2,true);
#endif
SynthesizeRule
yG2
yQ2}
nG1{yP1
ApplyGrammar
iS1
Grammar&tK2,nP1
bool
c4{if(tree.GetOptimizedUsing()==&tK2){
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Already optimized:  "
iL2
tree
lE2"\n"
<<std::flush;
#endif
return
t23
if(true){bool
changed
eW3
e23
t72){case
cNot:case
cNotNot:case
cAnd:case
cOr:for
iZ1
a=0
tV3
true))yS1
lC
cIf:case
cAbsIf:if(ApplyGrammar(tK2,xW
0),t72==cIf))yS1
for
iZ1
a=1
tV3
c4)yS1
break;yF3
for
iZ1
a=0
tV3
false))yS1}
if(changed){tree.Mark_Incompletely_Hashed(yQ2}
typedef
const
x83
short*lW3;std::pair<lW3,lW3>range=MyEqualRange(tK2.rule_list,tK2.rule_list+tK2.rule_count
cU3,OpcodeRuleCompare
xF());eO3
x83
short>rules;rules.xH3
range.second-range.first);for
y0
if(IsLogisticallyPlausibleParamsMatch(tM1
yR2
cU3))rules
c52*r);}
range.first=!rules
eU3?&rules[0]:0;range.second=!rules
eU3?&rules[rules
eJ3-1]+1:0;if(range.first!=range.second){
#ifdef DEBUG_SUBSTITUTIONS
if(range.first!=range.second)cH2"Input ("
<<FP_GetOpcodeName(t72)<<")["
<<tree.GetParamCount()<<"]"
;if(c4
cV2<<"(Logical)"
;x83
first=l52,prev=l52;e32
sep=", rules "
;for
y0
if(first==l52)first=prev=*r;iP1*r==prev+1)prev=*r;else
cH2
sep<<first;sep=","
;if(prev!=first)cV2<<'-'<<prev;first=prev=*r;}
}
if(first!=l52)cH2
sep<<first;if(prev!=first)cV2<<'-'<<prev;}
cV2<<": "
iL2
tree
lE2"\n"
<<std::flush;}
#endif
bool
changed
eW3
for
y0
#ifndef DEBUG_SUBSTITUTIONS
if(!IsLogisticallyPlausibleParamsMatch(tM1
yR2
cU3))yA1
#endif
if(TestRuleAndApplyIfMatch(tM1
cU3,c4){yS1
xY3}
if(changed){
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Changed."
<<std::endl;cV2<<"Output: "
iL2
tree
lE2"\n"
<<std::flush;
#endif
tree.Mark_Incompletely_Hashed(yQ2}
tree.SetOptimizedUsing(&tK2)i1
t23
yP1
ApplyGrammar
iS1
void*p,FPoptimizer_CodeTree::eR
yP
ApplyGrammar(*iS1
Grammar*)p
cU3);}
xL1
ApplyGrammars(FPoptimizer_CodeTree::eR{
#ifdef DEBUG_SUBSTITUTIONS
cV2<<iB3"grammar_optimize_round1\n"
;
#endif
n6
grammar_optimize_round1
cU3
nW
#ifdef DEBUG_SUBSTITUTIONS
cV2<<iB3"grammar_optimize_round2\n"
;
#endif
n6
grammar_optimize_round2
cU3
nW
#ifdef DEBUG_SUBSTITUTIONS
cV2<<iB3"grammar_optimize_round3\n"
;
#endif
n6
grammar_optimize_round3
cU3
nW
#ifndef FP_ENABLE_SHORTCUT_LOGICAL_EVALUATION
#ifdef DEBUG_SUBSTITUTIONS
cV2<<iB3"grammar_optimize_nonshortcut_logical_evaluation\n"
;
#endif
n6
grammar_optimize_nonshortcut_logical_evaluation
cU3
nW
#endif
#ifdef DEBUG_SUBSTITUTIONS
cV2<<iB3"grammar_optimize_round4\n"
;
#endif
n6
grammar_optimize_round4
cU3
nW
#ifdef FP_ENABLE_SHORTCUT_LOGICAL_EVALUATION
#ifdef DEBUG_SUBSTITUTIONS
cV2<<iB3"grammar_optimize_shortcut_logical_evaluation\n"
;
#endif
n6
grammar_optimize_shortcut_logical_evaluation
cU3
nW
#endif
#ifdef FP_ENABLE_IGNORE_IF_SIDEEFFECTS
#ifdef DEBUG_SUBSTITUTIONS
cV2<<iB3"grammar_optimize_ignore_if_sideeffects\n"
;
#endif
n6
grammar_optimize_ignore_if_sideeffects
cU3
nW
#endif
#ifdef DEBUG_SUBSTITUTIONS
cV2<<iB3"grammar_optimize_abslogical\n"
;
#endif
n6
grammar_optimize_abslogical
cU3
nW
#undef C
}
}
#endif
#ifdef FP_SUPPORT_OPTIMIZER
#include <algorithm>
#include <assert.h>
#include <cstring>
#include <cmath>
#include <memory> /* for auto_ptr */
using
l33
FUNCTIONPARSERTYPES;using
l33
lA1;using
t5;using
nG1;l33{yP1
TestImmedConstraints
lT1
bitmask,const
eR{e23
bitmask&ValueMask){case
Value_AnyNum:case
ValueMask:lC
x62:if(GetEvennessInfo
iS3
n72
Value_OddInt:if(GetEvennessInfo
iS3
x82
i11:if(GetIntegerInfo
iS3
n72
Value_NonInteger:if(GetIntegerInfo
iS3
x82
eY1:if(!IsLogicalValue(tree)cQ
nE1
SignMask){case
Sign_AnySign:lC
nD1:if(l81
n72
eZ1:if(l81
x82
Sign_NoIdea:if(l81
Unknown
cQ
nE1
OnenessMask){case
Oneness_Any:case
OnenessMask:lC
Oneness_One:if(!xY1
if(!lJ3
fp_abs(tree
x41),e62
1))cQ
lC
Oneness_NotOne:if(!xY1
lG3
fp_abs(tree
x41),e62
1))cQ
nE1
ConstnessMask){case
Constness_Any:lC
i01:if(!xY1
lC
Constness_NotConst:if(xY1
xY3
lD2}
tP1
x83
extent,x83
nbits,x93
eP2=x83
int>e72
nbitmap{private:static
const
x83
bits_in_char=8;static
const
x83
eQ2=(sizeof(eP2)*bits_in_char)/nbits;eP2
data[(extent+eQ2-1)/eQ2];e43
void
inc(lJ1,int
by=1){data[pos(index)]+=by*eP2(1<<y82);y81
void
dec(lJ1){inc(index,-1);}
int
get(lJ1
c01(data[pos(index)]>>y82)&mask()iT3
pos(lJ1)yP
index/eQ2
iT3
shift(lJ1)yP
nbits*(index%eQ2)iT3
mask()yP(1<<nbits)-1
iT3
mask(lJ1)yP
mask()<<y82;}
}
;e72
Needs{int
SubTrees:8;int
Others:8;int
l62:8;int
Immeds:8;nbitmap<iU2,2>SubTreesDetail;Needs(){std::memset(this,0,sizeof(*this));}
Needs
iS1
Needs&b){std::memcpy(this,&b,sizeof(b));}
Needs&eM1=iS1
Needs&b){std::memcpy(this,&b,sizeof(b))i1*this;}
}
yO1
Needs
CreateNeedList_uncached(eX&tL2{Needs
yQ1;for
lT1
a=0;a<params
y92;++a){const
eA2&lX3=ParamSpec_Extract
xF(params.param_list,a);e23
lX3.first){case
SubFunction:{cN&yU3
cN*tF1;yF
GroupFunction)++yQ1.Immeds;else{++iO2;assert(iH3.subfunc_opcode<VarBegin);yQ1.SubTreesDetail.inc
yZ3
lG1);}
++yQ1.l62;xY3
case
NumConstant:case
ParamHolder:++iN2;++yQ1.l62;xY3
eE3
yQ1;}
tK1
Needs&CreateNeedList(eX&tL2{typedef
std::map<eX*,Needs>eE1;static
eE1
yV1;eE1::y83
i=yV1.xU2&tL2;if(i!=yV1.cX1&tL2
return
i
eC2
i1
yV1.y43,std::make_pair(&params,CreateNeedList_uncached
xF(tL2))eC2;}
tK1
yZ2
CalculateGroupFunction
iS1
eA2&yA2
const
tC
info
yY3
lX3.first){case
NumConstant:{const
ParamSpec_NumConstant
xF&param=*iS1
ParamSpec_NumConstant
xF*tF1
i1
CodeTreeImmed
yZ3
constvalue);}
case
ParamHolder:{cM&yU3
cM*tF1
i1
info.GetParamHolderValueIfFound
yZ3
index);}
case
SubFunction:{cN&yU3
cN*tF1
tX
nS3;nS3
iH
param.lG1);nS3.lJ2).xH3
iH3
y92);for
lT1
a=0;a<iH3
y92;++a
nQ
tmp(CalculateGroupFunction
nF1
iH3.param_list,a),info));nS3
c91
tmp);}
nS3
iW1
i1
nS3;}
eE3
yZ2();}
}
nG1{yP1
IsLogisticallyPlausibleParamsMatch(eX&params,const
eR{Needs
yQ1(CreateNeedList
xF(tL2);size_t
tL3=yC
if(tL3<size_t(yQ1.l62))tM2
for
iZ1
a=0;a<tL3;++a){x83
opcode=xW
a)nC;e23
opcode){case
cImmed:if(yQ1.Immeds>0)--yQ1.Immeds;else--iN2;lC
iU2:case
cFCall:case
cPCall:--iN2;break;yF3
assert(opcode<VarBegin);if(iO2>0&&yQ1.SubTreesDetail.get(opcode)>0){--iO2;yQ1.SubTreesDetail.dec(opcode);}
else--iN2;}
}
if(yQ1.Immeds>0||iO2>0||iN2>0)tM2
if(params.match_type!=AnyParams){if(0||iO2<0||iN2<0)tM2}
lD2}
tK1
n31
TestParam
iS1
eA2&yA2
const
nP1
const
cZ&start_at,tC
info
yY3
lX3.first){case
NumConstant:{const
ParamSpec_NumConstant
xF&param=*iS1
ParamSpec_NumConstant
xF*tF1;if(!xY1
Value_t
imm=tree
x41;switch
yZ3
modulo){case
Modulo_None:lC
Modulo_Radians:imm=cK3
imm,yK
imm<xG1
imm
yN
if(imm>fp_const_pi
xF())imm-=fp_const_twopi
xF(e02
return
lJ3
imm,param.constvalue);}
case
ParamHolder:{cM&yU3
cM*tF1;if(!x3
return
info.SaveOrTestParamHolder
yZ3
index
cU3);}
case
SubFunction:{cN&yU3
cN*tF1;yF
GroupFunction){if(!x3
yZ2
xZ1=CalculateGroupFunction(yA2
info);
#ifdef DEBUG_SUBSTITUTIONS
DumpHashes(xZ1
lE2*iS1
void**)&xZ1
x41;cV2<<"\n"
;cV2<<*iS1
void**)&tree
x41;cV2<<"\n"
;DumpHashes(tree
lE2"Comparing "
iL2
xZ1
lE2" and "
iL2
tree
lE2": "
;cV2<<(xZ1
xI
tree)?"true"
:"false"
lE2"\n"
;
#endif
return
xZ1
xI
tree);}
cJ3!eK1){if(!x3
if(t72!=param.lG1
cQ
eE3
TestParams
yZ3
data
cU3,start_at,info,false);}
}
eE3
t23
tK1
e72
l31
x92
MatchInfo
xF
info;l31():start_at(),info(){}
}
yO1
class
MatchPositionSpec_PositionalParams:nQ1
l31
xF>{e43
iX2
MatchPositionSpec_PositionalParams
iZ1
n):eF1
l31
xF>(n){}
}
;e72
l72
x92
l72():start_at(){}
}
;class
yG:nQ1
l72>{e43
x83
trypos;iX2
yG
iZ1
n):eF1
l72>(n),trypos(0){}
}
yO1
n31
TestParam_AnyWhere
iS1
eA2&yA2
const
nP1
const
cZ&start_at,tC
info,cY2&used,bool
iX1{xP<yG>x8;x83
xA2(yG*)eK1;a=x8->trypos;goto
retry_anywhere_2;cO2
yG
l51);a=0;}
tM3
yC++a){if(used[a])yA1
retry_anywhere
yW3
TestParam(yA2
xW
a)xS3);yP3
used[a]=true;if(iX1
info.SaveMatchedParamIndex(a);x8->trypos=a
i1
n31(true,&*x8);}
}
retry_anywhere_2
yX3
goto
retry_anywhere;}
eE3
t23
tK1
e72
yD1
x92
MatchInfo
xF
info;cY2
used;iX2
yD1
iZ1
tL3):start_at(),info(),used(tL3){}
}
yO1
class
MatchPositionSpec_AnyParams:nQ1
yD1
xF>{e43
iX2
MatchPositionSpec_AnyParams
iZ1
n,size_t
m):eF1
yD1
xF>(n,yD1
xF(m)){}
}
yO1
n31
TestParams(eX&nN,const
nP1
const
cZ&start_at,tC
info,bool
iX1{if(nN.match_type!=AnyParams){if(xT!=tree.GetParamCount()cQ}
if(!IsLogisticallyPlausibleParamsMatch(nN
cU3))tM2
e23
nN.match_type){case
PositionalParams:{xP<cF>x8;x83
xA2(cF*)eK1;a=xT-1;goto
lK1;cO2
cF(xT);a=0;}
tM3
xT;++a){(yQ3=info;retry_positionalparams
yW3
TestParam(cW
a),xW
a)xS3);yP3
yA1}
}
lK1
yX3
info=(yQ3;goto
retry_positionalparams;}
if(a>0){--a;goto
lK1;}
info=c12
i1
t23
if(iX1
tN3
info.SaveMatchedParamIndex(a)i1
n31(true,&*x8);}
case
SelectedParams:case
AnyParams:{xP<t6>x8;cY2
used
l51);eO3
x83>iY2(xT);eO3
x83>yB2(xT);tN3{const
eA2
lX3=cW
a);iY2[a]=ParamSpec_GetDepCode(lX3);}
{x83
b=0;tN3
if(iY2[a]!=0)yB2[b++]=a;tN3
if(iY2[a]==0)yB2[b++]=a;}
x83
xA2(t6*)eK1;if(xT==0){a=0;goto
retry_anyparams_4;}
a=xT-1;goto
eG1;cO2
t6(xT
cU3.GetParamCount());a=0;if(xT!=0){c12=info;(*x8)[0].used=used;}
}
tM3
xT;++a){if(a>0){(yQ3=info;(yO3
used=used;}
retry_anyparams
yW3
TestParam_AnyWhere
xF(cW
yB2[a])cU3
xS3,used,iX1;yP3
yA1}
}
eG1
yX3
info=(yQ3;used=(yO3
used;goto
retry_anyparams;}
eH1:if(a>0){--a;goto
eG1;}
info=c12
i1
t23
retry_anyparams_4:if(nN.n1!=0){if(!TopLevel||!info.HasRestHolder(nN.n1)){eK
cI2;cI2.reserve
l51);for
lT1
b=0;b<yC++b){if(used[b])yA1
cI2
c52
xW
b));used[b]=true;if(iX1
info.SaveMatchedParamIndex(b);}
if(!info.SaveOrTestRestHolder(nN.n1,cI2)){goto
eH1;}
}
else{eA3&cI2=info.GetRestHolderValues(nN.n1
iY1
0;a<cI2
eJ3;++a){bool
found
eW3
for
lT1
b=0;b<yC++b){if(used[b])yA1
if(cI2[a]xI
xW
b))){used[b]=true;if(iX1
info.SaveMatchedParamIndex(b);found=true;xY3}
if(!found){goto
eH1;}
}
}
eE3
n31(true,xT?&*x8:0);}
case
GroupFunction:xY3
return
t23}
#endif
#ifdef FP_SUPPORT_OPTIMIZER
#include <algorithm>
#include <assert.h>
using
t5;using
nG1;l33{tK1
yZ2
yW1
iS1
eA2&yA2
tC
info,bool
inner=true
yY3
lX3.first){case
NumConstant:{const
ParamSpec_NumConstant
xF&param=*iS1
ParamSpec_NumConstant
xF*tF1
i1
CodeTreeImmed
yZ3
constvalue);}
case
ParamHolder:{cM&yU3
cM*tF1
i1
info.GetParamHolderValue
yZ3
index);}
case
SubFunction:{cN&yU3
cN*tF1
tX
tree;tD2
param.lG1);for
lT1
a=0;a<iH3
y92;++a
nQ
nparam=yW1
nF1
iH3.param_list,a
l04
true
c81
nparam);}
if
yZ3
data.n1!=0){eK
trees(info.GetRestHolderValues
yZ3
data.n1)yB
AddParamsMove(trees);if
l51==1){assert(tree.GetOpcode()==cAdd||tree.GetOpcode()==cMul||tree.GetOpcode()==cMin||tree.GetOpcode()==cMax||tree.GetOpcode()==cAnd||tree.GetOpcode()==cOr||tree.GetOpcode()==cAbsAnd||tree.GetOpcode()==cAbsOr);tree.eF2
0));}
else
if
l51==0
yY3
t72){case
cAdd:case
cOr:tree=nA1
0));lC
cMul:case
cAnd:tree=nA1
1));yF3
xY3}
}
if(inner)tree
iW1
i1
tree;}
eE3
yZ2();}
}
nG1{xL1
SynthesizeRule(t41
nP1
tC
info
yY3
rule.ruletype){case
ProduceNewTree:{tree.Become(yW1
nF1
rule.t51
0
l04
false)e02
case
ReplaceParams:yF3{eO3
x83>list=info.GetMatchedParamIndexes();std::sort(list.iJ2
list.end()iY1
list
eJ3;a-->0;)tree.i91
list[a]);for
lT1
a=0;a<rule.repl_param_count;++a
nQ
nparam=yW1
nF1
rule.t51
a
l04
true
c81
nparam);}
xY3}
}
}
#endif
#ifdef DEBUG_SUBSTITUTIONS
#include <sstream>
#include <cstring>
using
l33
FUNCTIONPARSERTYPES;using
l33
lA1;using
t5;using
nG1;l33
lA1{xL1
DumpMatch(t41
const
nP1
const
tC
info,bool
DidMatch,std::ostream&o){DumpMatch
yG2,DidMatch?iX3"match"
:iX3"mismatch"
,o);}
xL1
DumpMatch(t41
const
nP1
const
tC
info,e32
tO3,std::ostream&o){static
const
char
ParamHolderNames[][2]={"%"
,"&"
,"x"
,"y"
,"z"
,"a"
,"b"
,"c"
}
;o<<tO3<<" (rule "
<<(&rule-grammar_rules)<<")"
<<":\n  Pattern    : "
;{eA2
tmp;tmp.first=SubFunction;ParamSpec_SubFunction
tmp2;tmp2.data=rule
yR2;tmp.second=cG2
tmp2;DumpParam
xF(tmp,o);}
o<<"\n  Replacement: "
;DumpParams
xF(rule.t51
rule.repl_param_count,o)iV3
o<<"  Tree       : "
iL2
tree,o)iV3
if(!std::strcmp(tO3,iX3"match"
))DumpHashes(tree,o
iY1
0;a<info.cA
eJ3;++a){if(!info.cA[a].nX2)yA1
o<<"           "
<<ParamHolderNames[a]<<" = "
iL2
info.cA[a],o)iV3}
e11
info.lQ
eJ3;++b){if(!iW3
eH3)yA1
for
iZ1
a=0;a<iW3
eI3
eJ3;++a){o<<"         <"
<<b<<"> = "
iL2
iW3
eI3[a],o);o<<std::endl;}
}
o<<std::flush;}
}
#endif
#include <list>
#include <algorithm>
#ifdef FP_SUPPORT_OPTIMIZER
using
l33
FUNCTIONPARSERTYPES;l33{yP1
MarkIncompletes(FPoptimizer_CodeTree::eR{if(tree.Is_Incompletely_Hashed())lD2
bool
l82
eW3
x51
l82|=MarkIncompletes(xW
a));if(l82)tree.Mark_Incompletely_Hashed()i1
l82;}
xL1
FixIncompletes(FPoptimizer_CodeTree::eR{if(tree.Is_Incompletely_Hashed()){x51
FixIncompletes(xW
a)yB
e33);}
}
}
t5{lB
Sort()iZ3
Sort();}
lB
e33
bool
constantfolding){if(constantfolding)ConstantFolding(*this);else
Sort();data
xC
tK1
e72
cB
c03
Value_t
c13
yE1=0;
#if 0
long
double
value=Value;e9=crc32::calc(iS1
x83
char*)&value,sizeof(value));key^=(key<<24);
#elif 0
union{e72{x83
char
filler1[16]iK2
v;x83
char
filler2[16];}
buf2;e72{x83
char
filler3[sizeof
cX3)+16-sizeof(xE1)];e9;}
buf1;}
data;memset(&data,0,sizeof(data));data.buf2.v=Value;e9=data.buf1.key;
#else
int
exponent
iK2
nR2=std::frexp(Value,&tU2
e9=lT1(exponent+0x8000)&0xFFFF);if(nR2<0){nR2=-nR2;key=key^0xFFFF;}
else
key+=0x10000;nR2-=yF2;key<<=39;key|=n51(nR2+nR2)*e62
1u<<31))<<8;
#endif
lP
#ifdef FP_SUPPORT_COMPLEX_NUMBERS
nN1
T
cJ2
std::complex<T> >c03
std::complex<T>c13
cB<T>::lY3
cK2,Value.real());nB
fphash_t
temp;cB<T>::lY3
temp,Value.imag());yE1^=temp.hash2;cK2.hash2^=temp.hash1;}
}
;
#endif
#ifdef FP_SUPPORT_LONG_INT_TYPE
tP1
cJ2
long>yD
long
Value){e9=Value;lP
#endif
#ifdef FP_SUPPORT_GMP_INT_TYPE
tP1
cJ2
GmpInt>c03
GmpInt
c13
e9=Value.toInt();lP
#endif
xL1
xK2
xF::Recalculate_Hash_NoRecursion(){fphash_t
cK2(n51
Opcode)<<56,Opcode*iE3(0x1131462E270012B));Depth=1;e23
Opcode){case
cImmed:{cB
xF::lY3
cK2,Value
e02
case
iU2:{yE1|=n51
cO1<<48
lL1((n51
cO1)*11)^iE3(0x3A83A83A83A83A0);xY3
case
cFCall:case
cPCall:{yE1|=n51
cO1<<48
lL1((~n51
cO1)*7)^3456789;}
yF3{size_t
t61=0
e73
0;a<iS2;++a){if(iT2
nP2>t61)t61=iT2
nP2;yE1+=((iT2.tN2
hash1*(a+1))>>12)lL1
iT2.tN2
hash1
lL1(3)*iE3(0x9ABCD801357);cK2.hash2*=iE3(0xECADB912345)lL1(~iT2.tN2
hash2)^4567890;}
Depth+=t61;}
}
if(Hash!=cK2){Hash=cK2;lM2=0;}
}
lB
tE3{MarkIncompletes(*this);FixIncompletes(*this);}
}
#endif
#include <cmath>
#include <list>
#include <cassert>
#ifdef FP_SUPPORT_OPTIMIZER
using
l33
FUNCTIONPARSERTYPES;l33{using
t5
yO1
bool
x01
const
nP1
long
count,const
xK1::SequenceOpCode
xF&eQ,xK1::eP3&synth,size_t
max_bytecode_grow_length);static
const
e72
SinCosTanDataType{OPCODE
whichopcode;OPCODE
inverse_opcode;enum{eR2,nS2,nZ1,lM1}
;OPCODE
codes[4];}
SinCosTanData[12]={{cTan,cCot,{cSin,cCos,cCsc,cSec}
}
,{cCot,cCot,{cCos,cSin,cSec,cCsc}
}
,{cCos,cSec,{cSin,cTan,cCsc,cCot}
}
,{cSec,cCos,{cTan,cSin,cCot,cCsc}
}
,{cSin,cCsc,{cCos,cCot,cSec,cTan}
}
,{cCsc,cSin,{cCot,cCos,cTan,cSec}
}
,{cL2{tD3
cCosh,cM2,{tD3
cNop,{cL2
cNop,cCosh}
}
,{cCosh,cNop,{tD3
cL2
cNop}
}
,{cNop,cTanh,{cCosh,tD3
cM2,{cNop,tD3{cNop,cTanh,cCosh,cNop}
}
,{cNop,cCosh,{cTanh,tD3
cM2}
;}
t5{lB
SynthesizeByteCode(eO3
x83>&eN1,std
xM3
xF&Immed,size_t&stacktop_max){
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Making bytecode for:\n"
;l21
#endif
while(RecreateInversionsAndNegations()){
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"One change issued, produced:\n"
;l21
#endif
tE3;using
nG1;using
l33
lA1;const
void*g=cG2
grammar_optimize_recreate;while(ApplyGrammar(*iS1
Grammar*)g,*this)){tE3;}
}
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Actually synthesizing, after recreating inv/neg:\n"
;l21
#endif
xK1::eP3
synth;SynthesizeByteCode(synth,false
iM2.Pull(eN1,Immed,stacktop_max);}
lB
SynthesizeByteCode(xK1::eP3&synth,bool
MustPopTemps)const{y01*this))yP;}
for
iZ1
a=0;a<12;++a){const
SinCosTanDataType&data=SinCosTanData[a];if(data.whichopcode!=cNop)iC1!=data.whichopcode)yA1
c02
lZ3;lZ3.xA1);lZ3
iH
data.inverse_opcode);lZ3.yC2);y01
lZ3)){synth.tQ
else
iC1!=cInv)yA1
if(GetParam(0)nC!=data.inverse_opcode)yA1
y01
GetParam(0))){synth.tQ
size_t
found[4];e11
4;++b){c02
tree;if(data.tP3]==cNop){tD2
cInv);c02
n03;n03.xA1);n03
iH
data.tP3^2]);n03.yC2
c81
n03);}
else{tree.xA1
yB
eL3
data.tP3]);}
tree.yC2);found[b]=synth.xK3
tree);}
if(found[data.eR2
e3
nS2
tG
eR2]iM2.yT
nS2]);yB1
cDiv
tW
eR2
e3
lM1
tG
eR2]iM2.yT
lM1]);yB1
cMul
tW
nZ1
e3
lM1
tG
nZ1]iM2.yT
lM1]);yB1
cRDiv
tW
nZ1
e3
nS2
tG
nZ1]iM2.yT
nS2]);yB1
cMul,2,1
iM2.tQ
size_t
n_subexpressions_synthesized=SynthCommonSubExpressions(c92
e23
l92{case
iU2:synth.PushVar(GetVar());lC
cImmed:t71
GetImmed());lC
cAdd:case
cMul:case
cMin:case
cMax:case
cAnd:case
cOr:case
cAbsAnd:case
cAbsOr:iC1==cMul){bool
c23
eW3
yH
lX1
tD1&&isLongInteger(lX1
x41)){c11=makeLongInteger(lX1
x41);c02
tmp(*this,x93
c02::CloneTag());tmp.i91
a);tmp
iW1;if(x01
tmp,value,xK1::tU1
xF::AddSequence,synth,MAX_MULI_BYTECODE_LENGTH)){c23=true;xY3}
}
if(c23)xY3
int
yF1=0;cY2
done(GetParamCount(),false);c02
iQ;iQ
iH
l92;for(;;){bool
found
eW3
yH
done[a])yA1
if(synth.IsStackTop(lX1)){found=true;done[a]=true;lX1.n7
iQ
cS
lX1);if(++yF1>1){yU
2);iQ.yC2)yC1
iQ);yF1=yF1-2+1;}
}
}
if(!found)xY3
yH
done[a])yA1
lX1.n7
iQ
cS
lX1);if(++yF1>1){yU
2);iQ.yC2)yC1
iQ);yF1=yF1-2+1;}
}
if(yF1==0
yY3
l92{case
cAdd:case
cOr:case
cAbsOr:t71
0);lC
cMul:case
cAnd:case
cAbsAnd:t71
1);lC
cMin:case
cMax:t71
0);break;yF3
xY3++yF1;}
assert(n_stacked==1);xY3
case
cPow:{tW1
p0
i42
0);tW1
p1
i42
1);if(!p1
tD1||!isLongInteger
cR3||!x01
p0,makeLongInteger
cR3,xK1::tU1
xF::MulSequence,synth,MAX_POWI_BYTECODE_LENGTH)){p0.n7
p1.n7
yU
2);e21
cIf:case
cAbsIf:{x93
xK1::eP3::IfData
ifdata;GetParam(0)e93
SynthIfStep1(ifdata,l92;GetParam(1)e93
SynthIfStep2(ifdata);GetParam(2)e93
SynthIfStep3(ifdata
e02
case
cFCall:case
cPCall:{for
iZ1
a=0;a<l91++a)lX1.n7
yU
lT1)GetParamCount());yB1
0x80000000u|GetFuncNo(),0,0
e02
yF3{for
iZ1
a=0;a<l91++a)lX1.n7
yU
lT1)GetParamCount()e02}
synth.StackTopIs(*this);if(MustPopTemps&&n_subexpressions_synthesized>0){size_t
top=synth.GetStackTop(iM2.DoPopNMov(top-1-n_subexpressions_synthesized,top-1);}
}
}
l33{yP1
x01
const
nP1
long
count,const
xK1::SequenceOpCode
xF&eQ,xK1::eP3&synth,size_t
max_bytecode_grow_length){if
cW3!=0){xK1::eP3
backup=synth;tree.n7
size_t
bytecodesize_backup=synth.GetByteCodeSize();xK1::x01
count
e63
size_t
bytecode_grow_amount=synth.GetByteCodeSize()-bytecodesize_backup;if(bytecode_grow_amount>max_bytecode_grow_length){synth=backup
i1
t23
lD2}
else{xK1::x01
count,eQ,synth
yQ2}
}
#endif
#include <cmath>
#include <cassert>
#ifdef FP_SUPPORT_OPTIMIZER
using
l33
FUNCTIONPARSERTYPES;l33{using
t5;
#define FactorStack std xM3
const
e72
PowiMuliType{x83
opcode_square;x83
opcode_cumulate;x83
opcode_invert;x83
opcode_half;x83
opcode_invhalf;}
iseq_powi={cSqr,cMul,cInv,cSqrt,cRSqrt}
,iseq_muli={l52
x9
cNeg,l52,l52}
yO1
Value_t
cP1
const
PowiMuliType&c33,const
std
nA3,n82&stack)eQ3
1);while(IP<limit){if(n13
c33.opcode_square){if(!t42
eT3
2;yZ
opcode_invert){nS3=-nS3;yZ
opcode_half){if(nS3>xH1&&isEvenInteger(eT3
yF2;yZ
opcode_invhalf){if(nS3>xH1&&isEvenInteger(eT3
e62-0.5);++IP;yA1}
size_t
xB2=IP
iK2
lhs(1);if(n13
cFetch){lJ1=n43;if(index<y2||size_t(index-y2)>=lB2){IP=xB2;xY3
lhs=stack[index-y2];goto
yD2;}
if(n13
cDup){lhs=nS3;goto
yD2;yD2:t91
nS3);++IP
iK2
subexponent=cP1
c33
iK
if(IP>=limit||eN1[IP]!=c33.opcode_cumulate){IP=xB2;xY3++IP;stack.pop_back();nS3+=lhs*subexponent;yA1}
xY3
return
nS3;}
tK1
Value_t
ParsePowiSequence
iS1
std
nA3){n82
stack;t91
e62
1))i1
cP1
iseq_powi
iK}
tK1
Value_t
ParseMuliSequence
iS1
std
nA3){n82
stack;t91
e62
1))i1
cP1
iseq_muli
iK}
tK1
class
CodeTreeParserData{e43
iX2
CodeTreeParserData(bool
k_powi):stack(),clones(),keep_powi(k_powi){}
void
Eat
iZ1
tL3,OPCODE
opcode
nQ
xM;xM
iH
opcode);eK
params=Pop(tL3
yR1
tL2;if(!keep_powi)e23
opcode){case
cTanh:{yZ2
sinh,cosh;sinh
iH
cSinh);sinh
cS
xM
c43
sinh
iW1;cosh
iH
cCosh);cosh
c91
xM
c43
cosh
iW1
tX
pow;pow
iH
cPow);pow
c91
cosh);pow.yA
nU2));pow
iW1;xM
iH
cMul);xM.nB1
0,sinh);xM
c91
pow
e02
case
cTan:{yZ2
sin,cos;sin
iH
cSin);sin
cS
xM
c43
sin
iW1;cos
iH
cCos);cos
c91
xM
c43
cos
iW1
tX
pow;pow
iH
cPow);pow
c91
cos);pow.yA
nU2));pow
iW1;xM
iH
cMul);xM.nB1
0,sin);xM
c91
pow
e02
case
cPow:{iT1&p0=xM
l8
0);iT1&p1=xM
l8
1);if(p1
nC==cAdd){eK
mulgroup(p1.GetParamCount()iY1
0;a<p1.l91++a
nQ
pow;pow
iH
cPow);pow
cS
p0);pow
cS
p1
n93
pow
iW1;mulgroup[a
tQ3
pow);}
xM
iH
cMul
yR1
mulgroup);}
xY3
yF3
xY3
xM.e33!keep_powi);lA2,false);
#ifdef DEBUG_SUBSTITUTIONS
iA1<<tL3<<", "
<<FP_GetOpcodeName(opcode)<<"->"
<<FP_GetOpcodeName(xM
nC)<<": "
iK3
xM);iB1
xM);
#endif
t91
xM
cN2
EatFunc
iZ1
tL3,OPCODE
opcode,x83
funcno
nQ
xM=CodeTreeFuncOp
xF(opcode,funcno);eK
params=Pop(tL3
yR1
tL2;xM.yC2);
#ifdef DEBUG_SUBSTITUTIONS
iA1<<tL3<<", "
iK3
xM);iB1
xM);
#endif
lA2);t91
xM
cN2
AddConst(yL1
nQ
xM=CodeTreeImmed(value);lA2);Push(xM
cN2
AddVar
lT1
varno
nQ
xM=CodeTreeVar
xF(varno);lA2);Push(xM
cN2
SwapLastTwoInStack(){tA1
1
tQ3
tA1
2]cN2
Dup(){Fetch(lB2-1
cN2
Fetch
iZ1
which){Push(stack[which]);}
nN1
T>void
Push(T
tree){
#ifdef DEBUG_SUBSTITUTIONS
cV2<<iK3
tree);iB1
tree);
#endif
t91
tree
cN2
PopNMov
iZ1
target,size_t
source){stack[target]=stack[source];stack
xF3
target+1);}
yZ2
yE2{clones.clear()tX
nS3(stack.back());stack
xF3
lB2-1)i1
nS3;}
eK
Pop
iZ1
n_pop){eK
nS3(n_pop);for
lT1
n=0;n<n_pop;++n)nS3[n
tQ3
tA1
n_pop+n]);
#ifdef DEBUG_SUBSTITUTIONS
for
iZ1
n=n_pop;n-->0;){iA1
iL2
nS3[n]);iB1
nS3[n]);}
#endif
stack
xF3
lB2-n_pop)i1
nS3;}
size_t
GetStackTop(c01
lB2;}
private:void
FindClone(yZ2&,bool=true)yP;}
private:eK
stack;std::multimap<fphash_t,yZ2>clones;bool
keep_powi;private:CodeTreeParserData
iS1
CodeTreeParserData&);CodeTreeParserData&eM1=iS1
CodeTreeParserData&);}
yO1
e72
IfInfo{yZ2
eS2
tX
thenbranch;size_t
endif_location;IfInfo():eS2(),thenbranch(),endif_location(){}
}
;}
t5{lB
GenerateFrom
iS1
x93
FunctionParserBase
xF::Data&x33,bool
keep_powi){eK
xH2;xH2.xH3
x33.mVariablesAmount);for
lT1
n=0;n<x33.mVariablesAmount;++n){xH2
c52
CodeTreeVar
xF(n+iU2));}
GenerateFrom(x33,xH2,keep_powi);}
lB
GenerateFrom
iS1
x93
FunctionParserBase
xF::Data&x33,const
x5&xH2,bool
keep_powi){const
eO3
x83>&eN1=x33.mByteCode;const
std
xM3
xF&Immed=x33.mImmed;
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"ENTERS GenerateFrom()\n"
;
#endif
CodeTreeParserData
xF
sim(keep_powi);eO3
IfInfo
xF>eJ
eK3
IP=0,DP=0;;++IP){tO2:while(!eJ
eU3&&(eJ.eA==IP||(IP<n41&&n13
cJump&&eJ
e81.nX2))){c02
elsebranch=sim.yE2
nA2
eJ.back().eS2)nA2
eJ
e81)nA2
elsebranch)yR
3,cIf);eJ.pop_back();}
if(IP>=n41)break;x83
opcode=eN1[IP];if(eS3
cSqr||opcode==cDup||eS3
cInv&&!IsIntType
xF::nS3)||opcode==cNeg||opcode==cSqrt||opcode==cRSqrt||opcode==cFetch)){size_t
was_ip=IP
iK2
eD2
ParsePowiSequence
xF(eN1,IP,eJ
eU3?n41:eJ.eA,sim.xH
1);if(exponent!=e62
1.0)){xG
exponent
iU3);goto
tO2;}
if
eS3
cDup||opcode==cFetch||opcode==cNeg)l14
xT2=ParseMuliSequence
xF(eN1,IP,eJ
eU3?n41:eJ.eA,sim.xH
1);if(xT2!=e62
1.0)){xG
xT2)yR
2,cMul);goto
tO2;}
}
IP=was_ip;}
if(nB2>=iU2){lJ1=opcode-iU2
nA2
xH2[index]);}
else{e23
nB2){case
cIf:case
cAbsIf:{eJ
xF3
eJ
eJ3+1);c02
res(sim.yE2);eJ.back().eS2.swap(res);eJ.eA=n41;IP+=2;yA1}
case
cJump:{c02
res(sim.yE2);eJ
e81.swap(res);eJ.eA=eN1[IP+1]+1;IP+=2;yA1}
case
cImmed:xG
Immed[DP++]);lC
cDup:sim.Dup();lC
cNop:lC
cFCall:{x83
funcno=n43;assert(funcno<fpdata.mFuncPtrs.size());x83
params=x33.mFuncPtrs
n53
mParams;sim.EatFunc(params,nB2,funcno
e02
case
cPCall:{x83
funcno=n43;assert(funcno<fpdata.iI3.size());const
FunctionParserBase
xF&p=*x33.iI3
n53
mParserPtr;x83
params=x33.iI3
n53
mParams;x5
paramlist=sim.Pop(tL2;c02
tP2;tP2.GenerateFrom(*p.mData,paramlist)nA2
tP2
e02
case
cInv:xG
1
c32
cDiv);lC
cNeg
nC2
cNeg);break;xG
0
c32
cSub);lC
cSqr:xG
2
xN1
cSqrt:xG
yF2
xN1
cRSqrt:xG
e62-0.5)xN1
cCbrt:xG
e62
1)/e62
3)xN1
cDeg:xG
fp_const_rad_to_deg
xF())yG1
cRad:xG
fp_const_deg_to_rad
xF())yG1
cExp:iR)goto
yM3;xG
fp_const_e
xF()c32
cPow);lC
cExp2:iR)goto
yM3;xG
2.0
c32
cPow);lC
cCot
nC2
cTan);iR)x1
cCsc
nC2
cSin);iR)x1
cSec
nC2
cCos);iR)x1
cInt:
#ifndef __x86_64
iR)n23
1,cInt
e02
#endif
xG
yF2)tQ2
yR
1,cFloor);lC
cLog10
nC2
c53
fp_const_log10inv
xF())yG1
cLog2
nC2
c53
fp_const_log2inv
xF())yG1
cQ3:n33
c53
fp_const_log2inv
xF())yR
3,cMul);lC
cHypot:xG
2
iU3);tS3
xG
2
iU3)tQ2;xG
yF2
xN1
cSinCos:sim.Dup()yR
1,cSin);n33
cCos);lC
cSinhCosh:sim.Dup()yR
1,cSinh);n33
cCosh);lC
cRSub:tS3
case
cSub:iR)n23
2,cSub
e02
xG-1)yR
2,cMul)tQ2;lC
cRDiv:tS3
case
cDiv:iR||IsIntType
xF::nS3)n23
2,cDiv
e02
xG-1
iU3)yG1
cAdd:case
cMul:case
cMod:case
cPow:case
cEqual:case
cLess:case
cGreater:case
i51:case
cLessOrEq:case
cGreaterOrEq:case
cAnd:case
cOr:case
cAbsAnd:case
cAbsOr:sim.Eat(2,tB1
lC
cNot:case
cNotNot:case
cC3:case
cAbsNotNot
nC2
tB1
lC
cFetch:sim.Fetch(n43);lC
cPopNMov:{x83
stackOffs_target=n43;x83
stackOffs_source=n43;sim.PopNMov(stackOffs_target,stackOffs_source
e02
yF3
yM3:;x83
funcno=opcode-cAbs;assert(funcno<FUNC_AMOUNT);const
FuncDefinition&func=Functions[funcno]yR
func.params,tB1
xY3}
}
Become(sim.yE2);
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Produced tree:\n"
;l21
#endif
}
}
#endif
#include <algorithm>
#ifdef FP_SUPPORT_OPTIMIZER
#include <assert.h>
#define FP_MUL_COMBINE_EXPONENTS
l33{using
l33
FUNCTIONPARSERTYPES;using
t5
yO1
static
void
AdoptChildrenWithSameOpcode(eR{
#ifdef DEBUG_SUBSTITUTIONS
bool
nT2
eW3
#endif
for
l41
if(xW
a)nC==t72){
#ifdef DEBUG_SUBSTITUTIONS
if(!nT2)cH2"Before assimilation: "
cR
nT2=true;}
#endif
tree.AddParamsMove(xW
a).GetUniqueRef().lJ2),a);}
#ifdef DEBUG_SUBSTITUTIONS
if(nT2)cH2"After assimilation:   "
cR}
#endif
}
}
t5{xL1
ConstantFolding(eR{tree.Sort();
#ifdef DEBUG_SUBSTITUTIONS
void*c63=0;cV2<<"["
<<(&c63)<<"]Runs ConstantFolding for: "
cR
DumpHashes(tree
lE2
std::flush;
#endif
if(false){redo:;tree.Sort();
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"["
<<(&c63)<<"]Re-runs ConstantFolding: "
cR
DumpHashes(tree);
#endif
}
if(t72!=cImmed){yD3
p=CalculateResultBoundaries(tree);if(p
yI&&p
e61&&p
yM==p
tG1{nU
p
yM);nD}
if(false){ReplaceTreeWithOne:nU
e62
1));goto
do_return;ReplaceTreeWithZero:nU
xG1;goto
do_return;ReplaceTreeWithParam0:
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Before replace: "
;cV2<<std::hex<<'['
eJ1
hash1<<','
eJ1
hash2<<']'<<std::dec
cR
#endif
tree.eF2
0));
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"After replace: "
;cV2<<std::hex<<'['
eJ1
hash1<<','
eJ1
hash2<<']'<<std::dec
cR
#endif
cJ
c73(t72){case
cImmed:lC
iU2:lC
cAnd:case
cAbsAnd
cK
bool
c5
eW3
for
l41{if(!c83
a)))c5=true;cA3
a),t72==cAbsAnd)){case
xX3
t7
iF2:iZ);lC
lZ1
c73
l51){case
0:iD
1:tD2
t72==cAnd?cNotNot:cAbsNotNot);cJ
yF3
cZ2
cAnd||!c5)if(ConstantFolding_AndLogic(tB2
e21
cOr:case
cAbsOr
cK
bool
c5
eW3
for
l41{if(!c83
a)))c5=true;cA3
a),t72==cAbsOr)tN1
iD
l03
iZ);lC
lZ1
c73
l51){case
0
t7
1:tD2
t72==cOr?cNotNot:cAbsNotNot);cJ
yF3
cZ2
cOr||!c5)if(ConstantFolding_OrLogic(tB2
e21
cNot:case
cC3:{x83
n61
0;e23
c93){case
cEqual:n61
i51;lC
i51:n61
cEqual;lC
cLess:n61
cGreaterOrEq;lC
cGreater:n61
cLessOrEq;lC
cLessOrEq:n61
cGreater;lC
cGreaterOrEq:n61
cLess;lC
cNotNot:n61
cNot;lC
cNot:n61
cNotNot;lC
cC3:n61
cAbsNotNot;lC
cAbsNotNot:n61
cC3;break;yF3
xY3
if(opposite){tD2
OPCODE(opposite)yB
SetParamsMove(xW
0).GetUniqueRef().lJ2));cJ
c73(lY1
0)cU3
cQ1){case
iF2
t7
l03
iD
lZ1
cZ2
cNot&&GetPositivityInfo(xW
0))==iF2)tD2
cC3);if(c93==cIf||c93==cAbsIf
nQ
iZ2=xW
0);iT1&ifp1=iZ2
l8
1);iT1&ifp2=iZ2
l8
2);if(ifp1
nC
iY3
ifp1
cQ1
cD3
ifp1
nC==cNot?cNotNot:cAbsNotNot);tR2
c43
n63)cE3
nO2;p2
tT3
iI
if(ifp2
nC
iY3
ifp2
cQ1
cD3
t72);tR2);n63)cE3
iH
ifp2
nC==cNot?cNotNot:cAbsNotNot);p2
tT3
l8
0)iI
e21
cNotNot:case
cAbsNotNot:{if(c83
0)))n73
cA3
0),t72==cAbsNotNot)){case
xX3
t7
iF2:iD
lZ1
cZ2
cNotNot&&GetPositivityInfo(xW
0))==iF2)tD2
cAbsNotNot);if(c93==cIf||c93==cAbsIf
nQ
iZ2=xW
0);iT1&ifp1=iZ2
l8
1);iT1&ifp2=iZ2
l8
2);if(ifp1
nC
iY3
ifp1
cQ1{tree.SetParam(0,iZ2
l8
0)yB
AddParam(ifp1)cE3
nO2;p2
tT3
iI
if(ifp2
nC
iY3
ifp2
cQ1
cD3
t72);tR2);n63
yB
AddParam(ifp2
yB
eL3
iZ2
nC);cJ}
e21
cIf:case
cAbsIf:{if(ConstantFolding_IfOperations(tB2
xY3
case
cMul:{NowWeAreMulGroup:;AdoptChildrenWithSameOpcode(tree)iK2
nH1=e62
1);size_t
lC2=0;bool
nI1
eW3
x51{if(!xW
tC1
yA1
Value_t
immed=xW
a)x41;if(immed==xG1
goto
ReplaceTreeWithZero;nH1*=immed;++lC2;}
if(lC2>1||(lC2==1&&lJ3
nH1,e62
1))))nI1=true;if(nI1){
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"cMul: Will add new "
iJ3
nH1<<"\n"
;
#endif
for
l41
if(xW
tC1{
#ifdef DEBUG_SUBSTITUTIONS
cV2<<" - For that, deleting "
iJ3
xW
a)x41;cV2<<"\n"
;
#endif
tU3(!lJ3
nH1,e62
1)))tree
cS
eA1
nH1));c73
l51){case
0:iD
1:n73
yF3
if(ConstantFolding_MulGrouping(tB2
if(ConstantFolding_MulLogicItems(tB2
e21
cAdd
cK
Value_t
nD2=0.0;size_t
lC2=0;bool
nI1
eW3
x51{if(!xW
tC1
yA1
Value_t
immed=xW
a)x41;nD2+=immed;++lC2;}
if(lC2>1||(lC2==1&&nD2==xG1)nI1=true;if(nI1){
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"cAdd: Will add new "
iJ3
nD2<<"\n"
;cV2<<"In: "
cR
#endif
for
l41
if(xW
tC1{
#ifdef DEBUG_SUBSTITUTIONS
cV2<<" - For that, deleting "
iJ3
xW
a)x41;cV2<<"\n"
;
#endif
tU3(!(nD2==e62
0.0)))tree
cS
eA1
nD2));c73
l51){case
0
t7
1:n73
yF3
if(ConstantFolding_AddGrouping(tB2
if(ConstantFolding_AddLogicItems(tB2
e21
cMin
cK
size_t
yI2=0;yD3
e4;x51{while(a+1<tree.GetParamCount()&&xW
a)xI
xW
a+1)))iZ+1);yE3
max.cF3(!e4
e61||(p
tG1<e4
tG1){e4
nL3=p
nL3;e4
e61=true;yI2=a;}
}
if(e4
e61)for
l41{yE3
min.cF3
a!=yI2&&p
yM>=e4
tG1
tU3
l51==1){n73
e21
cMax
cK
size_t
yI2=0;yD3
eY;x51{while(a+1<tree.GetParamCount()&&xW
a)xI
xW
a+1)))iZ+1);yE3
min.cF3(!eY
yI||p
yM>eY
yM)){eY
yM=p
yM;eY
yI=true;yI2=a;}
}
if(eY
yI){for
l41{yE3
max.cF3
a!=yI2&&(p
tG1<eY
yM){iZ);}
}
}
if
l51==1){n73
e21
cEqual:case
i51:case
cLess:case
cGreater:case
cLessOrEq:case
cGreaterOrEq:if(ConstantFolding_Comparison(tB2
lC
cAbs:{yD3
tY
xW
0));if
iE
n73
if
iF{tD2
cMul
yB
yA
e62
1)));goto
NowWeAreMulGroup;}
if(c93==cMul){iT1&p=xW
0);eK
n83;eK
cP2
e73
0;a<p.l91++a){tY
p
n93
if
iE{n83
c52
p
n93}
if
iF{cP2
c52
p
n93}
}
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"Abs: mul group has "
<<n83
eJ3<<" pos, "
<<cP2
eJ3<<"neg\n"
;
#endif
if(!n83
eU3||!cP2
eU3){
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"AbsReplace-Before: "
iL2
tree
lE2"\n"
<<std::flush;DumpHashes
nV2);
#endif
yZ2
e13;e13
iH
cMul
iY1
0;a<p.l91++a){tY
p
n93
if(iE||iF){}
else
e13
cS
p
n93}
e13
iW1
tX
nB3;nB3
iH
cAbs);nB3
c91
e13);nB3
iW1
tX
iG
cMul);mulgroup
c91
nB3);cA1
AddParamsMove(n83);if(!cP2
eU3){if(cP2
eJ3%2)cA1
yA
nU2));cA1
AddParamsMove(cP2);}
tree.Become
eH2);
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"AbsReplace-After: "
;DumpTree
nV2
lE2"\n"
<<std::flush;DumpHashes
nV2);
#endif
goto
NowWeAreMulGroup;}
}
xY3
#define HANDLE_UNARY_CONST_FUNC(funcname) nP){nU funcname(lR));nD
case
cLog:i83(fp_log);if(c93==cPow
nQ
pow=xW
0);if(GetPositivityInfo(pow
l8
0))==iF2)iV1
t2
yB
lU
if(GetEvennessInfo(pow
l8
1))==iF2)iV1()tX
abs;abs
iH
cAbs);abs
c91
pow
c43
abs.Rehash
t2);pow.nB1
0,abs
yB
lU}
iP1
c93==cAbs
nQ
pow=xW
0)l8
0);if(pow
nC==cPow)iV1()tX
abs;abs
iH
cAbs);abs
c91
pow
c43
abs.Rehash
t2);pow.nB1
0,abs
yB
lU}
lC
cAcosh:i83(fp_acosh);lC
cAsinh:i83(fp_asinh);lC
cAtanh:i83(fp_atanh);lC
cAcos:i83(fp_acos);lC
cAsin:i83(fp_asin);lC
cAtan:i83(fp_atan);lC
cCosh:i83(fp_cosh);lC
cSinh:i83(fp_sinh);lC
cTanh:i83(fp_tanh);lC
cSin:i83(fp_sin);lC
cCos:i83(fp_cos);lC
cTan:i83(fp_tan);lC
cCeil:if(n5
i83(fp_ceil);lC
cTrunc:if(n5
i83(fp_trunc);lC
cFloor:if(n5
i83(fp_floor);lC
cInt:if(n5
i83(fp_int);lC
cCbrt:i83(fp_cbrt);lC
cSqrt:i83(fp_sqrt);lC
cExp:i83(fp_exp);lC
cLog2:i83(fp_log2);lC
cLog10:i83(fp_log10);lC
cQ3:if
lI
fp_log2(lR)*xW
nC3
cArg:i83(fp_arg);lC
cConj:i83(fp_conj);lC
cImag:i83(fp_imag);lC
cReal:i83(fp_real);lC
cPolar:if
lI
fp_polar
e51
lC
cMod:if
lI
fp_mod
e51
lC
cAtan2:{yD3
tY
xW
yP2
p1=tZ
1));nP&&lJ3
lR,xG1){if(p1
e61&&(p1
tG1<xG1{nU
fp_const_pi
cH3
if(p1
yI&&p1
yM>=tE1
xG1;nD}
if(eI1
lJ3
xW
i8,xG1){if(p0
e61&&(p0
tG1<xG1{nU-fp_const_pihalf
cH3
if
cN3
p0
yM>xG1{nU
fp_const_pihalf
cH3}
if
lI
fp_atan2
e51
if((p1
yI&&p1
yM>xG1||(p1
e61&&(p1
tG1<fp_const_negativezero
xF())nQ
yJ2;yJ2
iH
cPow);yJ2
c91
xW
1));yJ2.yA
nU2));yJ2
iW1
tX
yK2;yK2
iH
cMul);yK2
c91
xW
0));yK2
c91
yJ2);yK2
cY
cAtan
yB
nB1
0,yK2
yB
i91
1);e21
cPow:{if(ConstantFolding_PowOperations(tB2
xY3
case
cDiv:nP&&eI1
xW
i8!=tE1
lR/xW
nC3
cInv:nP&&lR!=tE1
e62
1)/lR);nD
lC
cSub:if
lI
lR-xW
nC3
cNeg:nP){nU-lR);nD
lC
cRad:nP){nU
RadiansToDegrees
eG2
cDeg:nP){nU
DegreesToRadians
eG2
cSqr:nP){nU
lR*lR);nD
lC
cExp2:i83(fp_exp2);lC
cRSqrt:nP){nU
e62
1)/fp_sqrt
eG2
cCot:c22
fp_tan(lZ
cSec:c22
fp_cos(lZ
cCsc:c22
fp_sin(lZ
cHypot:if
lI
fp_hypot
e51
lC
cRDiv:case
cRSub:case
cDup:case
cFetch:case
cPopNMov:case
cSinCos:case
cSinhCosh:case
cNop:case
cJump:lC
cPCall:case
cFCall:xY3
do_return:;
#ifdef DEBUG_SUBSTITUTIONS
cV2<<"["
<<(&c63)<<"]Done ConstantFolding, result: "
cR
DumpHashes(tree);
#endif
}
}
#endif
#ifdef FP_SUPPORT_OPTIMIZER
t5{xL1
yD3::set_abs(nL
bool
has_negative=!min.known||min.val<e62);bool
has_positive=!cG3||max.val>e62);bool
crosses_axis=has_negative&&has_positive;cI1
xF
newmax;if(min.cF3
cG3)newmax.set(fp_max(i61,i71);if(crosses_axis
cI3
e62));cJ3
min.cF3
cG3
cI3
fp_min(i61,i71);iP1
min.known
cI3
i61);else
min.set(i71;}
max=newmax;}
xL1
yD3::set_neg(){std::swap(min,max);min.val=-min.val;max.val=-max.val;}
yP1
IsLogicalTrueValue
iS1
yD3&p,bool
abs){if(nB
IsIntType
xF::nS3){if(p
yI&&p
yM>=e62
1))lD2
if(!abs&&p
e61
t43<=nU2)lD2}
cJ3
p
yI&&p
yM>=yF2)lD2
if(!abs&&p
e61
t43<=e62-0.5))lD2
eE3
t23
yP1
IsLogicalFalseValue
iS1
yD3&p,bool
abs){if(nB
IsIntType
xF::nS3){if(abs)eG3
e61
l61
1);else
eG3
yI&&p
e61&&p
yM>nU2
l61
1);}
cJ3
abs)eG3
e61
l61
0.5);else
eG3
yI&&p
e61&&p
yM>e62-0.5)l61
0.5);}
}
}
#endif
#ifdef FP_SUPPORT_OPTIMIZER
using
l33
FUNCTIONPARSERTYPES;using
t5;t5{tK1
yD3
CalculateResultBoundaries
iS1
eR
#ifdef DEBUG_SUBSTITUTIONS_extra_verbose
{using
l33
FUNCTIONPARSERTYPES;yD3
tmp=CalculateResultBoundaries_do(tree
lE2"Estimated boundaries: "
;if(tmp
yI)cV2<<tmp
yM;else
cV2<<"-inf"
;cV2<<" .. "
;if(tmp
e61)cV2<<tmp
nL3;else
cV2<<"+inf"
;cV2<<": "
iL2
tree
lE2
std::endl
i1
tmp;}
tK1
yD3
yZ2::CalculateResultBoundaries_do
iS1
eR
#endif
{iS
yH1(-fp_const_pihalf
xF(),fp_const_pihalf
xF());iS
pi_limits(-fp_const_pi
xF(),fp_const_pi
xF());iS
abs_pi_limits(xH1,fp_const_pi
xF());iS
plusminus1_limits(nU2,e62
1));using
l33
std;e23
t72){case
cImmed:nM
tree
x41
cU3
x41)t83
cAnd:case
cAbsAnd:case
cOr:case
cAbsOr:case
cNot:case
cC3:case
cNotNot:case
cAbsNotNot:case
cEqual:case
i51:case
cLess:case
cLessOrEq:case
cGreater:case
cGreaterOrEq:{nM
xH1,e62
1));}
case
cAbs:tW3
set_abs();tK
cLog:tW3
tS2
fp_log);nD3
fp_log);tK
cLog2:tW3
tS2
fp_log2);nD3
fp_log2);tK
cLog10:tW3
tS2
fp_log10);nD3
fp_log10);tK
cAcosh:tW3
min.tL1
cGreaterOrEq
tH1
fp_acosh
tR3
cGreaterOrEq
tH1
fp_acosh);tK
cAsinh:tW3
min.set(fp_asinh);tO
set(fp_asinh);tK
cAtanh:tW3
min.n3-1),fp_atanh
tR3
cLess
tH1
fp_atanh);tK
cAcos:lD
nM(tO
cF3(tO
val)<e62
1))?fp_acos(tO
val):xH1,(m
yI&&(m
yM)>=nU2)?fp_acos(m
yM):fp_const_pi
xF());}
case
cAsin:tW3
min.n3-1),fp_asin,yH1
yM
tR3
cLess
tH1
fp_asin,yH1
tG1;tK
cAtan:tW3
min.set(fp_atan,yH1
yM);tO
set(fp_atan,yH1
tG1;tK
cAtan2:{nP&&lJ3
lR,xG1)yP
abs_pi_limits;}
if(eI1
lJ3
xW
i8,xG1)yP
yH1;eE3
pi_limits;}
case
cSin:lD
bool
x11=!m
yI||!tO
known||(tO
val-m
yM)>=(yK
x11)tM
Value_t
min=cK3
m
yM,yK
min<xG1
min
yN
Value_t
max=cK3
tO
val,yK
max<xG1
max
yN
if(max<min)max
yN
bool
y21=(min<=fp_const_pihalf
xF()&&max>=fp_const_pihalf
xF());bool
nJ1=(min<=cD&&max>=cD);if(y21&&nJ1)tM
if(nJ1)nM
nU2,nW2
if(y21)nM
yL2
e62
1));nM
yL2
nW2}
case
cCos:lD
if(m
yI)m
yM+=fp_const_pihalf
xF();if(xI2
tO
val+=fp_const_pihalf
xF();bool
x11=!m
yI||!tO
known||(tO
val-m
yM)>=(yK
x11)tM
Value_t
min=cK3
m
yM,yK
min<xG1
min
yN
Value_t
max=cK3
tO
val,yK
max<xG1
max
yN
if(max<min)max
yN
bool
y21=(min<=fp_const_pihalf
xF()&&max>=fp_const_pihalf
xF());bool
nJ1=(min<=cD&&max>=cD);if(y21&&nJ1)tM
if(nJ1)nM
nU2,nW2
if(y21)nM
yL2
e62
1));nM
yL2
nW2}
case
cTan:{nM);}
case
cCeil:lD
tO
i81
cFloor:lD
m
yI1
tK
cTrunc:lD
m
yI1
tO
i81
cInt:lD
m
yI1
tO
i81
cSinh:tW3
min.set(fp_sinh);tO
set(fp_sinh);tK
cTanh:tW3
min.set(fp_tanh,plusminus1_limits.min);tO
set(fp_tanh,plusminus1_limits.max);tK
cCosh:lD
if(m
yI){if(xI2{if(m
yM>=xH1&&tO
val>=xG1{m
yM
xS}
iP1(m
yM)<xH1&&tO
val>=xG1
l14
tmp
xS
if(tmp>tO
val)tO
val=tmp;m
yM=e62
1);}
else{m
yM
xS
std::swap(m
yM,tO
val);}
}
cJ3
m
yM>=xG1{m.tL
m
yM=fp_cosh(m
yM);}
else{m.tL
m
yM=e62
1);}
}
}
else{m
yI=true;m
yM=e62
1);if(xI2{m
yM=fp_cosh(tO
val);m.tL}
else
m.tL}
tK
cIf:case
cAbsIf:{yD3
res1=tZ
1));yD3
res2=tZ
2));if(!res2
yI)res1
yI
eW3
iP1
res1
yI&&(res2
yM)<res1
yM)res1
yM=res2
yM;if(!res2
e61)res1.tL
iP1
res1
e61&&(res2
tG1>res1
tG1
res1
nL3=res2
nL3
i1
res1;}
case
cMin:{bool
iT
eW3
bool
iU
eW3
e83;x7
m
tZ3
m
yI)iT
iN3
yI||(m
yM)<nF3)nF3=m
yM;if(!xI2
iU
iN3
e61||(tO
val)<nG3
nH3=tO
val;}
if(iT)nK3
iU)nQ3
return
nR3
cMax:{bool
iT
eW3
bool
iU
eW3
e83;x7
m
tZ3
m
yI)iT
iN3
yI||m
yM>nF3)nF3=m
yM;if(!xI2
iU
iN3
e61||tO
val>nG3
nH3=tO
val;}
if(iT)nK3
iU)nQ3
return
nR3
cAdd:{e83(xH1,xG1;x7
item=tZ
a));if(item
yI)nF3+=item
yM;else
nK3
item
e61)nH3+=item
nL3;else
nQ3
if(!nI3&&!nJ3)xY3
if(nI3&&nJ3&&nF3>nG3
std::swap(nF3,nG3
i1
nR3
cMul:{e72
Value{enum
nT3{tT2,lG2,PlusInf}
;nT3
eB
iK2
value;Value(nT3
t):eB(t),value(0){}
Value
cX3
v):eB(tT2),value(v){}
bool
cQ2
c01
eB==lG2||(eB==tT2&&value<xG1;}
void
eM1*=iS1
Value&rhs){if(eB==tT2&&rhs.eB==tT2)value*=rhs.value;else
eB=(cQ2)!=rhs.cQ2)?lG2:PlusInf);}
iD2<iS1
Value&rhs
c01(eB==lG2&&rhs.eB!=lG2)||(eB==tT2&&(rhs.eB==PlusInf||(rhs.eB==tT2&&value<rhs.value)));}
}
;e72
yJ1{Value
yN2,yO2;yJ1():yN2(Value::PlusInf),yO2(Value::lG2){}
void
xJ2
Value
cM3,const
Value&value2){cM3*=value2;if(cM3<yN2)yN2=cM3;if(yO2<cM3)yO2=cM3;}
}
;e83(nM3
x7
item
tZ3
item
yI&&!item
e61)nM);Value
iP3=nI3?Value(nF3):xC2
lG2);Value
nU3=nJ3?Value(nG3:xC2
PlusInf);Value
nV3=item
yI?Value(item
yM):xC2
lG2);Value
nW3=item
e61?Value(item
tG1:xC2
PlusInf);yJ1
range;range.xJ2
iP3,nV3);range.xJ2
iP3,nW3);range.xJ2
nU3,nV3);range.xJ2
nU3,nW3);if(range.yN2.eB==Value::tT2)nF3=range.yN2.value;else
nK3
range.yO2.eB==Value::tT2)nH3=range.yO2.value;else
nQ3
if(!nI3&&!nJ3)xY3
if(nI3&&nJ3&&nF3>nG3
std::swap(nF3,nG3
i1
nR3
cMod:{yD3
x=tZ
yP2
y=tZ
1));if(y
e61){if(y
nL3>=xG1{if(!x
yI||(x
yM)<xG1
nM-y
nL3,y
tG1;i03
xH1,y
tG1;}
cJ3!x
e61||(x
tG1>=xG1
nM
y
nL3,-y
tG1;i03
y
nL3,fp_const_negativezero
xF());}
}
i03);}
case
cPow:{if(eI1
xW
i8==xG1{nM
nM3}
nP&&lR==xG1{nM
xH1,xG1;}
nP&&lJ3
lR
nH2
nM
nM3}
if(eI1
xW
i8>xH1&&GetEvennessInfo(xW
1))==iF2)l14
eD2
xW
i8;yD3
tmp=tZ
yP2
nS3;nI3=true;nF3=0;if(tmp
yI&&tmp
yM>=xG1
nF3=t33
tmp
yM,tU2
iP1
tmp
e61&&tmp
nL3<=xG1
nF3=t33
tmp
nL3,tU2
nQ3
if(tmp
yI&&tmp
e61){nJ3=true;nH3=fp_max(fp_abs(tmp
yM),fp_abs(tmp
tG1);nH3=t33
nH3,tU2
eE3
nS3;}
yD3
tY
xW
yP2
p1=tZ
1));TriTruthValue
p0_positivity=cN3(p0
yM)>=xG1?iF2:(p0
e61&&(p0
tG1<xH1?l03
Unknown);TriTruthValue
cR2=GetEvennessInfo(xW
1));TriTruthValue
eZ=Unknown;e23
p0_positivity
tN1
eZ=iF2;lC
l03{eZ=cR2;xY3
yF3
e23
cR2
tN1
eZ=iF2;lC
l03
lC
Unknown:{if(eI1!t42
xW
i8)&&xW
i8>=xG1{eZ=iF2;}
xY3}
c73(eZ
tN1
l14
min=xH1;if
cN3
p1
yI){min=t33
p0
yM,p1
yM);if(p0
yM<xH1&&(!p1
e61||p1
nL3>=xG1&&min>=xG1
min=xH1;}
if
cN3
p0
yM>=xH1&&p0
e61&&p1
e61)l14
max=t33
p0
nL3,p1
tG1;if(min>max)std::swap(min,max);nM
min,max);}
nM
min,false);}
case
l03{nM
false,fp_const_negativezero
xF());}
yF3{xY3
e21
cNeg:tW3
set_neg();tK
cSub:yJ
cNeg);tmp2
tX3
tmp
iH
cAdd);tmp
tY3
tmp
c91
tmp2
i0
cInv:{c02
lW-1))i0
cDiv:yJ
cInv);tmp2
tX3
tmp
iH
xC1
AddParamMove(tmp2
i0
cRad:yV
xC1
yA
fp_const_rad_to_deg
xF())i0
cDeg:yV
xC1
yA
fp_const_deg_to_rad
xF())i0
cSqr:{c02
lW
2))i0
cExp:yV
cPow);tmp.yA
fp_const_e
xF()));tmp.nJ
0)i0
cExp2:yV
cPow);tmp.yA
nX3
tmp.nJ
0)i0
cCbrt:tW3
min.set(fp_cbrt);tO
set(fp_cbrt);tK
cSqrt:lD
if(m
yI)m
yM=(m
yM)<xH1?0:fp_sqrt(m
yM);if(xI2
tO
val=(tO
val)<xH1?0:fp_sqrt(tO
val);tK
cRSqrt:{c02
lW-0.5))i0
cHypot:{yZ2
xsqr,ysqr,add,sqrt;xsqr
tY3
xsqr.yA
nX3
ysqr
tX3
ysqr.yA
nX3
xsqr
iH
cPow);ysqr
iH
cPow);add
c91
xsqr);add
c91
ysqr);add
iH
cAdd);sqrt
c91
add);sqrt
iH
cSqrt)i1
CalculateResultBoundaries(sqrt);}
case
cQ3:yJ
cLog2);tmp2
tY3
tmp
iH
cMul);tmp
c91
tmp2);tmp.nJ
1)i0
cCot:yJ
cTan)x6
lH
cSec:yJ
cCos)x6
lH
cCsc:yJ
cSin)x6
CalculateResultBoundaries(tmp);}
lC
cRDiv:case
cRSub:case
cDup:case
cFetch:case
cPopNMov:case
cSinCos:case
cSinhCosh:case
cNop:case
cJump:case
iU2:lC
cArg:case
cConj:case
cImag:case
cReal:case
cPolar:lC
cPCall:lC
cFCall:xY3
nM);}
tK1
TriTruthValue
GetIntegerInfo
iS1
eR{e23
t72){case
cImmed:return
t42
tree
x41)?iF2:xX3
t83
cFloor:case
cCeil:case
cTrunc:case
cInt:return
iF2
t83
cAnd:case
cOr:case
cNot:case
cNotNot:case
cEqual:case
i51:case
cLess:case
cLessOrEq:case
cGreater:case
cGreaterOrEq:return
iF2
t83
cIf:{TriTruthValue
a=GetIntegerInfo(xW
1));TriTruthValue
b=GetIntegerInfo(xW
2));if(a==b)return
a
xO2
case
cAdd:case
cMul:{for
l41
if(GetIntegerInfo(xW
a))!=iF2)return
Unknown
i1
iF2;}
yF3
xY3
return
Unknown;}
yP1
IsLogicalValue
iS1
eR{e23
t72){case
cImmed:return
lJ3
tree
x41,xG1||lJ3
tree
x41,e62
1))t83
cAnd:case
cOr:case
cNot:case
cNotNot:case
cAbsAnd:case
cAbsOr:case
cC3:case
cAbsNotNot:case
cEqual:case
i51:case
cLess:case
cLessOrEq:case
cGreater:case
cGreaterOrEq:nZ
cMul:{for
l41
if(!c83
a))cQ
lD2}
case
cIf:case
cAbsIf:yP
c83
1))&&c83
2));}
yF3
xY3
return
t23}
#endif
#ifdef FP_SUPPORT_OPTIMIZER
using
l33
FUNCTIONPARSERTYPES;
#if defined(__x86_64) || !defined(FP_SUPPORT_CPLUSPLUS11_MATH_FUNCS)
# define CBRT_IS_SLOW
#endif
#if defined(DEBUG_POWI) || defined(DEBUG_SUBSTITUTIONS)
#include <cstdio>
#endif
l33
xK1{extern
const
x83
char
powi_table[256];}
l33{using
t5
yO1
bool
IsOptimizableUsingPowi(long
immed,long
penalty=0){xK1::eP3
synth;synth.PushVar(iU2);size_t
bytecodesize_backup=synth.GetByteCodeSize();xK1::x01
immed,xK1::tU1
xF::MulSequence,c92
size_t
bytecode_grow_amount=synth.GetByteCodeSize()-bytecodesize_backup
i1
bytecode_grow_amount<size_t(MAX_POWI_BYTECODE_LENGTH-penalty);}
xL1
ChangeIntoRootChain(nP1
bool
l13,long
tY2,long
tZ2){while(tZ2>0
t82
cCbrt);t92);tmp.e33
xD2--tZ2;}
while(tY2>0
t82
cSqrt);if(l13){tmp
iH
cRSqrt);l13
eW3}
t92);tmp.e33
xD2--tY2;}
if(l13
t82
cInv);t92
xD2}
}
tK1
e72
RootPowerTable{static
const
Value_t
RootPowers[(1+4)*(1+3)];}
yO1
const
Value_t
t9(1+4)*(1+3)]={e62
1)lS
2)lS
2*2)lS
2*2*2)lS
2*2*2*2)lS
3)lS
3*2)lS
3*2*2)lS
3*2*2*2)lS
3*2*2*2*2)lS
3*3)lS
3*3*2
yG3
yG3*2
yG3*2*2)lS
3*3*3
eY2
eY2*2
eY2*2*2
eY2*2*2*2)}
;e72
PowiResolver{static
const
x83
MaxSep=4;static
x03
i13=5;typedef
int
cO3;typedef
long
x43;typedef
long
tP;e72
yS2{yS2():n_int_sqrt(0),n_int_cbrt(0),sep_list(),n01(0){}
int
n_int_sqrt;int
n_int_cbrt;int
tT1
MaxSep];tP
n01;}
yO1
static
yS2
CreatePowiResult
cX3
exponent){yS2
nS3;cO3
tA=FindIntegerFactor(tU2
if(tA==0){
#ifdef DEBUG_POWI
i02"no factor found for %Lg\n"
,(cP3);
#endif
return
nS3;}
nS3.n01=y31
exponent,tA);x43
eT2=EvaluateFactorCost(tA,0,0,0)+cC
nS3.n01);int
s_count=0;int
i23=0;int
nZ3=0;
#ifdef DEBUG_POWI
i02"orig = %Lg\n"
,(cP3);i02"plain factor = "
iL3"%ld\n"
,(int)tA,(long)eT2);
#endif
for
lT1
n_s=0;n_s<MaxSep;++n_s){int
xD=0;x43
yK1=eT2;cO3
yX1=tA;for(int
s=1;s<i13*4;++s){
#ifdef CBRT_IS_SLOW
if(s>=i13)break;
#endif
int
n_sqrt=s%i13;int
n_cbrt=s/i13;if(n_sqrt+n_cbrt>4)yA1
Value_t
lN1=exponent;lN1-=t9
s];iE1=FindIntegerFactor(lN1);if(xT2!=0){tP
xN=y31
lN1,xT2);x43
cost=EvaluateFactorCost(xT2,s_count+n_sqrt,i23+n_cbrt,nZ3+1)+cC
xN);
#ifdef DEBUG_POWI
i02"Candidate sep %u (%d*sqrt %d*cbrt)factor = "
iL3"%ld (for %Lg to %ld)\n"
,s,n_sqrt,n_cbrt,xT2,(long)cost
cX2
lN1,(long)xN);
#endif
if(cost<yK1){xD=s;yX1=xT2;yK1=cost;}
}
}
if(!xD)break;
#ifdef DEBUG_POWI
i02"CHOSEN sep %u (%d*sqrt %d*cbrt)factor = "
iL3"%ld, exponent %Lg->%Lg\n"
,xD,xD%i13,xD/i13,yX1,yK1
cX2(exponent)cX2(exponent-t9
xD]));
#endif
nS3.tT1
n_s]=xD
eX3-=t9
xD];s_count+=xD%i13;i23+=xD/i13;eT2=yK1;tA=yX1;nZ3+=1;}
nS3.n01=y31
exponent,tA);
#ifdef DEBUG_POWI
i02"resulting exponent is %ld (from exponent=%Lg, best_factor=%Lg)\n"
,nS3.n01,(cP3
cX2
tA);
#endif
while(tA%2==0){++nS3
e52;tA/=2;}
while(tA%3==0){++nS3.n_int_cbrt;tA/=3;eE3
nS3;}
private:static
x43
cC
tP
xN){static
std::map
cS2
iM;if(xN<0){x43
cost=22
i1
cost+cC-xN);}
std::map
cS2::y83
i=iM.xU2
xN);if(i!=iM.cX1
xN)return
i
eC2;std::pair
cS2
nS3(xN,0.0);x43&cost=nS3.i63
while(xN>1){int
xT2=0;if(xN<256){xT2=xK1::powi_table[xN];if(xT2&128)xT2&=127;else
xT2=0;if(xT2&64)xT2=-(xT2&63)-1;}
if(xT2){cost+=cC
xT2);xN/=xT2;yA1}
if(!(xN&1)){xN/=2;cost+=6;}
else{cost+=7;xN-=1;}
}
iM.y43,nS3)i1
cost;}
cB1
tP
y31
yL1,iE1)yP
makeLongInteger(value*e62
xT2));}
cB1
bool
yM1
yL1,iE1)l14
v=value*e62
xT2)i1
isLongInteger(v);}
cB1
cO3
FindIntegerFactor(yL1){iE1=(2*2*2*2);
#ifdef CBRT_IS_SLOW
#else
xT2*=(3*3*3);
#endif
cO3
nS3=0;if(yM1
value,xT2)){nS3=xT2;while((xT2%2)==0&&yM1
value,xT2/2))nS3=xT2/=2;while((xT2%3)==0&&yM1
value,xT2/3))nS3=xT2/=3;}
#ifdef CBRT_IS_SLOW
if(nS3==0){if(yM1
value,3
y03
3;}
#endif
return
nS3;}
static
int
EvaluateFactorCost(int
xT2,int
s,int
c,int
nmuls){x03
x13=6;
#ifdef CBRT_IS_SLOW
x03
eU2=25;
#else
x03
eU2=8;
#endif
int
nS3=s*x13+c*eU2;while(xT2%2==0){xT2/=2;nS3+=x13;}
while(xT2%3==0){xT2/=3;nS3+=eU2;}
nS3+=nmuls
i1
nS3;}
}
;}
t5{yP1
yZ2::RecreateInversionsAndNegations(bool
prefer_base2){bool
changed=false
e73
0;a<l91++a)if(lX1.RecreateInversionsAndNegations(prefer_base2))yS1
if(changed){exit_changed:Mark_Incompletely_Hashed(yQ2
e23
l92{case
cMul:{eK
nE2
tX
nF2,cR1;if(true){bool
nK1=false
iK2
xE2=0
e73
tI1
i12
tI
0)i22
tI
1)tD1){nK1=true;xE2=tI
i8;xY3}
if(nK1)l14
immeds=1.0
e73
tI1
tD1){immeds*=powgroup
x41;yN1}
for
iZ1
a=l91
a-->0;nQ&powgroup=lX1;if(powgroup
i12
tI
0)i22
tI
1)tD1
nQ&log2=tI
0);log2.lD1
log2
iH
cQ3);log2.yA
t33
immeds,e62
1)/xE2)));log2
iW1;xY3}
}
}
for
iZ1
a=tI1
i12
tI
1)tD1){iT1&exp_param=tI
1)iK2
eD2
exp_param
x41;if(cZ1,nU2)){lD1
nE2
c52
lX1
c43
yN1
iP1
exponent<xH1&&t42
exponent)nQ
iV;iV
iH
cPow);iV
cS
tI
0));iV.yA-exponent));iV
iW1;nE2
c52
iV);lD1
yN1}
iP1
powgroup
i22!nF2.nX2){nF2=tI
0);lD1
yN1
iP1
powgroup
nC==cQ3&&!cR1.nX2){cR1=powgroup;lD1
yN1}
if(!nE2
eU3){changed=true
tX
cF1;cF1
iH
cMul);cF1
iF1
nE2);cF1
iW1
tX
iG
cMul);cA1
SetParamsMove
eM
if(cA1
IsImmed()&&fp_equal
eH2
x41
nH2
eL3
cInv)tN
cF1);}
cJ3
cA1
GetDepth()>=cF1
nP2
tC2
cDiv
iG1
tN
cF1);}
else{eL3
cRDiv)tN
cF1
iG1;}
}
}
if(nF2.nX2
nQ
iG
l92;cA1
SetParamsMove
eM
while(cA1
RecreateInversionsAndNegations(prefer_base2))cA1
tE3;eL3
cQ3)tN
nF2
iG1;yS1}
if(cR1.nX2
nQ
iG
cMul);mulgroup
c91
cR1
l8
1));cA1
AddParamsMove
eM
while(cA1
RecreateInversionsAndNegations(prefer_base2))cA1
tE3;DelParams();eL3
cQ3)tN
cR1
l8
0)iG1;yS1
e21
cAdd:{eK
i32
e73
l91
a-->0;)if(eY3
cMul){nG2
y41:tX&mulgroup=cT2
for
iZ1
b=cA1
l91
b-->0;){if
eH2
l8
b).lV1
xT2=mulgroup
l8
b)x41;lG3
xT2
xU
y41;}
cA1
lD1
cA1
i91
b
tA2
iP1
lJ3
xT2,e62-2)))eN
y41;}
cA1
lD1
cA1
i91
b);cA1
yA
e62
2))tA2}
}
if(t0){cA1
tB
mulgroup);yN1}
iP1
eY3
cDiv&&!IsIntType
xF::nS3){nG2
y51:tX&cF1=cT2
if(cF1
l8
0)tD1){lG3
cF1
l8
0)x41
xU
y51;}
cF1.lD1
cF1.i91
0);cF1
iH
cInv
tA2}
if(t0)eN
y51;}
cF1.tB
cF1);yN1}
iP1
eY3
cRDiv&&!IsIntType
xF::nS3){nG2
xD1:tX&cF1=cT2
if(cF1
l8
1)tD1){lG3
cF1
l8
i8
xU
xD1;}
cF1.lD1
cF1.i91
1);cF1
iH
cInv
tA2}
if(t0)eN
xD1;}
cF1.tB
cF1);yN1}
if(!i32
eU3){
#ifdef DEBUG_SUBSTITUTIONS
i02"Will make a Sub conversion in:\n"
);fflush(stdout);l21
#endif
yZ2
yT2;yT2
iH
cAdd);yT2
iF1
i32);yT2
iW1
tX
cS1;cS1
iH
cAdd);cS1
iF1
lJ2));cS1
iW1;if(cS1
tD1&&lJ3
cS1
x41,xG1
tC2
cNeg);eC);}
cJ3
cS1
nP2==1
tC2
cRSub);eC)eV3}
iP1
yT2
nC==cAdd
tC2
cSub)eV3
eC
l8
0)iY1
1;a<yT2.l91++a
nQ
eV2;eV2
iH
cSub);eV2
iF1
lJ2));eV2.yC2)tN
eV2);eC
n93}
}
else{eL3
cSub)eV3
eC);}
}
#ifdef DEBUG_SUBSTITUTIONS
i02"After Sub conversion:\n"
);fflush(stdout);l21
#endif
e21
cPow:{iT1&p0
i42
0);iT1&p1
i42
1);if(p1
tD1){if(p1
x41!=xH1&&!t42
p1
x41)){eG
yS2
r=eG
CreatePowiResult(fp_abs
cR3);if(r.n01!=0){bool
lH2
eW3
if(p1
x41<xH1&&r.tT1
0]==0&&r
e52>0){lH2=true;}
#ifdef DEBUG_POWI
i02"Will resolve powi %Lg as powi(chain(%d,%d),%ld)"
cX2
fp_abs
cR3,r
e52,r.n_int_cbrt,r.n01);for
lT1
n=0;n<eG
MaxSep;++n){if(r
i52==0)break;int
n_sqrt=r
i52%eG
i13;int
n_cbrt=r
i52/eG
i13;i02"*chain(%d,%d)"
,n_sqrt,n_cbrt);}
i02"\n"
);
#endif
yZ2
cU2
i42
0)tX
yU2=cU2;yU2.lD1
ChangeIntoRootChain(yU2,lH2,r
e52,r.n_int_cbrt);yU2
iW1
tX
pow;if(r.n01!=1){pow
iH
cPow);pow
c91
yU2);pow.yA
e62
r.n01)));}
else
pow.swap(yU2)tX
mul;mul
iH
cMul);mul
c91
pow);for
lT1
n=0;n<eG
MaxSep;++n){if(r
i52==0)break;int
n_sqrt=r
i52%eG
i13;int
n_cbrt=r
i52/eG
i13
tX
eW2=cU2;eW2.lD1
ChangeIntoRootChain(eW2,false,n_sqrt,n_cbrt);eW2
iW1;mul
c91
eW2);}
if(p1
x41<xH1&&!lH2){mul
iW1;eL3
cInv);nB1
0,mul);i91
1);}
else{eL3
cMul);SetParamsMove(mul.lJ2));}
#ifdef DEBUG_POWI
l21
#endif
yS1
xY3}
}
if(GetOpcode()==cPow&&(!p1
tD1||!isLongInteger
cR3||!IsOptimizableUsingPowi
xF(makeLongInteger
cR3))){if(p0
tD1&&p0
x41>e62
0.0)){if(prefer_base2)l14
yV2=fp_log2(p0
x41);lG3
yV2
nH2
i91
0);}
else{n0
eA1
yV2))eX3
cS
p1
t81
nB1
t1}
eL3
cExp2);yS1}
else
l14
yV2=fp_log(p0
x41);lG3
yV2
nH2
i91
0);}
else{n0
eA1
yV2))eX3
cS
p1
t81
nB1
t1}
eL3
cExp);yS1}
}
iP1
GetPositivityInfo(p0)==iF2){if(prefer_base2
nQ
log;log
iH
cLog2);log
cS
p0);log
iW1;n0
p1)eX3
c91
log
t81
eL3
cExp2);nB1
t1
yS1}
else{yZ2
log;log
iH
cLog);log
cS
p0);log
iW1;n0
p1)eX3
c91
log
t81
eL3
cExp);nB1
t1
yS1}
}
e21
cDiv:{if(GetParam(0)tD1&&lJ3
GetParam(0)x41
nH2
eL3
cInv);i91
0);}
xY3
yF3
xY3
if(changed)goto
exit_changed
i1
changed;}
}
#endif
#ifdef FP_SUPPORT_OPTIMIZER
using
l33
FUNCTIONPARSERTYPES;l33{using
t5;class
eF3{size_t
nL1;size_t
eH;size_t
eI;size_t
lO1;size_t
t3;size_t
t4;size_t
n71;e43
eF3():nL1(0),eH(0),eI(0),lO1(0),t3(0),t4(0),n71(0){}
void
i43
OPCODE
op){nL1+=1
i33
cCos)++eH
i33
cSin)++eI
i33
cSec)++eH
i33
cCsc)++eI
i33
cTan)++lO1
i33
cCot)++lO1
i33
cSinh)++t4
i33
cCosh)++t3
i33
cTanh)++n71;}
size_t
GetCSEscore()const{size_t
nS3=nL1
i1
nS3;}
int
NeedsSinCos()const{bool
y61=(nL1==(eH+eI+lO1));if((lO1&&(eI||eH))||(eI&&eH)){if(y61)return
1
i1
2;eE3
0;}
int
NeedsSinhCosh()const{bool
y61=(nL1==(t3+t4+n71));if((n71&&(t4||t3))||(t4&&t3)){if(y61)return
1
i1
2;eE3
0;}
size_t
MinimumDepth()const{size_t
n_sincos=std::min(eH,eI);size_t
n_sinhcosh=std::min(t3,t4);if(n_sincos==0&&n_sinhcosh==0)return
2
i1
1;}
}
yO1
class
TreeCountType:public
std::multimap<fphash_t,std::pair<eF3,yZ2> >{}
;xL1
FindTreeCounts(tJ1&nI2,const
nP1
OPCODE
xF2,bool
skip_root=false){cX
i=nI2.xU2
nJ2);if(!skip_root){bool
found
eW3
for(;i!=nI2.cX1
nJ2;++i){if(tree
xI
i
eC2.second)){i
eC2.first.i43
xF2);found=true;xY3}
if(!found){eF3
count;count.i43
xF2);nI2.y43,std::make_pair(nJ2,std::make_pair
cW3
cU3)));}
}
x51
FindTreeCounts(nI2,xW
a),t72);}
e72
yW{bool
BalanceGood;bool
FoundChild;}
yO1
yW
lP1
iT1&root,iT1&cS3{if(root
xI
cS3){yW
nS3={true,true}
i1
nS3;}
yW
nS3={true,false}
;if(root
nC==cIf||root
nC==t03{yW
cond=lP1
root
l8
0),cS3;yW
xV=lP1
root
l8
1),cS3;yW
y4=lP1
root
l8
2),cS3;if
l23||xV
yX||y4
yX){nS3
yX=true;}
nS3
eD=((xV
yX==y4
yX)||l23
i62)&&(cond
eD||(xV
yX&&y4
yX))&&(xV
eD||l23
i62)&&(y4
eD||l23
i62);}
else{bool
iH1
eW3
bool
nM1=false
eK3
b=root.GetParamCount(),a=0;a<b;++a){yW
tmp=lP1
root
l8
a),cS3;if(tmp
yX)nS3
yX=true;if(tmp
eD==false)iH1=true;iP1
tmp
yX)nM1=true;}
if(iH1&&!nM1)nS3
eD
eW3
eE3
nS3;}
yP1
cW2
iR1
i53
const
nP1
const
xK1::eP3&synth,const
tJ1&nI2){for
iZ1
b=tree.GetParamCount(),a=0;a<b;++a){iT1&leaf=xW
a);cX
synth_it;for(x93
tJ1::const_iterator
i=nI2.y73
i!=nI2.end();++i){if(i->first!=leaf.GetHash())yA1
const
eF3&occ
nY2
first;size_t
score=occ.GetCSEscore();iT1&candidate
nY2
i63
if(lF2
candidate))yA1
if(leaf
nP2<occ.MinimumDepth())yA1
if(score<2)yA1
if(lP1
i53
leaf)eD==false)continue
l43
if(cW2(i53
leaf,synth,nI2))lD2
eE3
t23
yP1
iI1
iT1&y53,iT1&expr){yY1
y53
lF3
expr))lD2
yY1
iI1
y53
l8
a),expr
y03
true
i1
t23
yP1
GoodMomentForCSE
iR1
y53,iT1&expr){if(y53
nC==cIf)lD2
yY1
y53
lF3
expr))lD2
size_t
i72=0;yY1
iI1
y53
l8
a),expr))++i72
i1
i72!=1;}
}
t5{tK1
size_t
yZ2::SynthCommonSubExpressions(xK1::xI1
const{if(e91
0)return
0;size_t
stacktop_before=synth.GetStackTop();tJ1
nI2;FindTreeCounts(nI2,*this,GetOpcode(),true);for(;;){size_t
yW2=0;
#ifdef DEBUG_SUBSTITUTIONS_CSE
cV2<<"Finding a CSE candidate, root is:"
<<std::y11*this);
#endif
cX
cs_it(nI2.end());for(cX
j=nI2.y73
j!=nI2.end();){cX
i(j++);const
eF3&occ
nY2
first;size_t
score=occ.GetCSEscore();iT1&tree
nY2
i63
#ifdef DEBUG_SUBSTITUTIONS_CSE
cV2<<"Score "
<<score<<":\n"
<<std::flush;DumpTreeWithIndent(tree);
#endif
if(lF2
tree))xZ
if(tree
nP2<occ.MinimumDepth())xZ
if(score<2)xZ
if(lP1*this
cU3)eD==false)xZ
if(cW2(*this
cU3,synth,nI2)){yA1}
if(!GoodMomentForCSE(*this
cU3))xZ
score*=tree
nP2;if(score>yW2){yW2=score;cs_it=i;}
}
if(yW2<=0){
#ifdef DEBUG_SUBSTITUTIONS_CSE
cV2<<"No more CSE candidates.\n"
<<std::flush;
#endif
xY3
iT1&tree=cs_it
eC2.i63
#ifdef DEBUG_SUBSTITUTIONS_CSE
cV2<<iX3"Common Subexpression:"
;DumpTree
xF(tree
lE2
std::endl;
#endif
#if 0
int
n11=occ.NeedsSinCos();int
i9=occ.NeedsSinhCosh()tX
i82,i92,yX2,yY2;if(n11){i82
eX2
i82
iH
cSin);i82
iW1;i92
eX2
i92
iH
cCos);i92
iW1;if(lF2
i82)||lF2
i92))i73==2){nI2.xG2
yA1}
n11=0;}
}
if(i9){yX2
eX2
yX2
iH
cSinh);yX2
iW1;yY2
eX2
yY2
iH
cCosh);yY2
iW1;if(lF2
yX2)||lF2
yY2)){if(i9==2){nI2.xG2
yA1}
i9=0;}
}
#endif
tree.SynthesizeByteCode(synth,false);nI2.xG2
#ifdef DEBUG_SUBSTITUTIONS_CSE
synth.x73
Dump<0>(lE2"Done with Common Subexpression:"
;DumpTree
xF(tree
lE2
std::endl;
#endif
#if 0
if(n11)i73==2||i9){synth.eL1}
yB1
cSinCos,1,2)yC1
i82,1)yC1
i92,0);}
if(i9)i73)synth.eL1
if(i9==2){synth.eL1}
yB1
cSinhCosh,1,2)yC1
yX2,1)yC1
yY2,0);}
#endif
eE3
xV3
stacktop_before;}
}
#endif
#ifdef FP_SUPPORT_OPTIMIZER
tK1
lU1
xF::iA2{using
t5;CopyOnWrite()tX
tree;tree.GenerateFrom(*mData);FPoptimizer_Optimize::ApplyGrammars(tree);eO3
x83>cT3;std
xM3
xF
immed;size_t
stacktop_max=0;tree.SynthesizeByteCode(cT3,immed,stacktop_max);if(mData->mStackSize!=stacktop_max){mData->mStackSize=x83(stacktop_max);
#if !defined(FP_USE_THREAD_SAFE_EVAL) && \
    !defined(FP_USE_THREAD_SAFE_EVAL_WITH_ALLOCA)
mData->mStack
xF3
stacktop_max);
#endif
}
mData->mByteCode.swap(cT3);mData->mImmed.swap(immed);}
#define FUNCTIONPARSER_INSTANTIATE_EMPTY_OPTIMIZE(type) tP1>lU1<type>::iA2{}
#ifdef FP_SUPPORT_MPFR_FLOAT_TYPE
i93(MpfrFloat)
#endif
#ifdef FP_SUPPORT_GMP_INT_TYPE
i93(GmpInt)
#endif
#ifdef FP_SUPPORT_COMPLEX_DOUBLE_TYPE
i93(std::complex<double>)
#endif
#ifdef FP_SUPPORT_COMPLEX_FLOAT_TYPE
i93(std::complex<float>)
#endif
#ifdef FP_SUPPORT_COMPLEX_LONG_DOUBLE_TYPE
i93(std::complex<long
double>)
#endif
#define FUNCTIONPARSER_INSTANTIATE_OPTIMIZE(type) x73 lU1<type>::iA2;
#ifndef FP_DISABLE_DOUBLE_TYPE
iA3(double)
#endif
#ifdef FP_SUPPORT_FLOAT_TYPE
iA3(float)
#endif
#ifdef FP_SUPPORT_LONG_DOUBLE_TYPE
iA3(long
double)
#endif
#ifdef FP_SUPPORT_LONG_INT_TYPE
iA3(long)
#endif
#endif // FP_SUPPORT_OPTIMIZER

#endif