summaryrefslogtreecommitdiff
path: root/gcc/ipa-str-reorg-instance-interleave.c
blob: f171359b661e9c77d4e37bd0ab22b59048ad4fc5 (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
/* Interprocedural structure reorganization
   Copyright (C) 2019-2020 Free Software Foundation, Inc.

  Contributed by Gary Oblock <gary@amperecomputing.com>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */

#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
#include "tree-ssa.h"
#include "tree-ssa-loop-ivopts.h"
#include "tree-dfa.h"
#include "gimple.h"
#include "tree-pass.h"
#include "cgraph.h"
#include "gimple-iterator.h"
#include "pretty-print.h"
#include "ipa-structure-reorg.h"
#include "dumpfile.h"
#include "tree-pretty-print.h"
#include "gimple-pretty-print.h"
#include "langhooks.h"
#include "stringpool.h"
#include "stor-layout.h"
#include "diagnostic-core.h"
#include "ssa.h"
#include "tree-ssanames.h"
#include "cfghooks.h"
#include "function.h"
#include "cfgloop.h"
#include "wide-int.h"

typedef struct acc_base_info acc_base_info_t;
typedef struct acc_info acc_info_t;
typedef struct varInfo varInfo_t;

static void wrangle_ssa_type( tree, Info_t*);
//static bool print_internals (gimple *, void *);
static void str_reorg_instance_interleave_qual_part ( Info *);
static void str_reorg_instance_interleave_type_part ( Info *);
static void header ( bool);
static void print_var_infos ( FILE *, std::vector<varInfo_t> &);
static void compress_acc_infos ( std::vector <acc_info_t>);
static void print_acc_info ( FILE *, acc_info_t *);
static void print_acc_infos ( FILE *, std::vector <acc_info_t>);
static bool acc_lt ( const acc_info_t&, const acc_info_t&);
static bool acc_eq ( const acc_info_t&, const acc_info_t&);
static bool all_but_field_eq ( const acc_info_t&, const acc_info_t&);
static double cut_off_eq_single_pool( double);
static double alignment_effect( unsigned HOST_WIDE_INT);
static void tell_me_about_ssa_name ( tree, int);
static void analyze_access ( tree , acc_info_t *);
static void create_new_types ( Info_t *);
static void create_a_new_type ( Info_t *, tree);
static unsigned int reorg_perf_qual ( Info *);
static tree find_coresponding_field ( tree, tree);
static void remove_default_def ( tree, struct function *);
static void set_lhs_for ( gimple *, tree);
static basic_block make_bb ( char *, basic_block);

// These are local to this file by design
#define REORG_SP_PTR_PREFIX "_reorg_SP_ptr_type_"
#define REORG_SP_PREFIX "_reorg_base_type_"
#define REORG_SP_BASE_PREFIX "_reorg_base_var_"

// TBD Delete all this after sending a note on it
// to the gcc mailing list.
#define USE_BUILT_IN_FREE 1

/*
0000 ssa_verify error loc_3
0001 tree_class_check err in interleave
0010 ssa_verify error arr_46
0011 ssa_verify error loc_3
0100 ssa_verify error loc_3
0101 ssa_verify error arr_46
0110 ssa_verify error arr_46
0111 ssa_verify error arr_46
1000 ssa_verify error loc_3
1001 bad failure: walk return bogus op
1010 bad failure: walk return bogus op
1011 bad failure: walk return bogus op
1100 bad failure: walk return bogus op
1101 bad failure: walk return bogus op
1110 bad failure: walk return bogus op
1111 bad failure: walk return bogus op
*/

// These are dummy values tha alway result the reorganization
#define SINGLE_POOL_RAW_SKIP_IT      0.10
#define SINGLE_POOL_RAW_DO_IT_ALWAYS 0.90
#define SINGLE_POOL_ABS_SKIP_IT      0.05
#define SINGLE_POOL_ABS_DO_IT_ALWAYS 0.10
  
int
str_reorg_instance_interleave_qual ( Info *info)
{
  // this is the qualification code for instance interleaving
  //
  str_reorg_instance_interleave_qual_part ( info);

  // this modifiies the qualified types.
  //
  str_reorg_instance_interleave_type_part ( info);
  return 0;
}

int
str_reorg_instance_interleave_trans ( Info *info)
{
  if ( info->show_all_reorg_cands )
  {
    fprintf ( info->reorg_dump_file, "Start of str_reorg_instance_interleave_trans:\n");
    print_program ( info->reorg_dump_file, PRINT_FORMAT, 4, info);
  }

  fprintf ( stderr, "Bypassing str_reorg_instance_interleave_trans for experiment\n");
  return 0;

  DEBUG ("INTERNALS PRINT\n");
  DEBUG_F (apply_to_all_gimple, print_internals, true, (void *)info);
  
  struct cgraph_node *node;
  FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)  {
    struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
    // Ulgy GCC idiom with global pointer to current function.
    push_cfun ( func);
    if ( info->show_transforms )
      {
        fprintf( info->reorg_dump_file, "Function \"%s\":\n",
		 //IDENTIFIER_POINTER( DECL_NAME( func)));
		 //IDENTIFIER_POINTER( DECL_NAME( func->decl)));
		 lang_hooks.decl_printable_name ( node->decl, 2));
      }

    basic_block bb;
    FOR_EACH_BB_FN ( bb, func)
      {

	if( info->show_transforms )
	  {
	    fprintf( info->reorg_dump_file, "  Transforming BB%i:\n",
		     bb->index);
	  }

	gimple_stmt_iterator outer_gsi;
	gimple_stmt_iterator next_gsi;
	for ( outer_gsi = gsi_start_bb ( bb); !gsi_end_p ( outer_gsi); outer_gsi = next_gsi )
	  {
	    next_gsi = outer_gsi;
	    gsi_next ( &next_gsi);
	    // Every statement that uses a reorg type needs to
	    // be examined. Some are harmless and are skipped
	    // whereas others are transformed. However, anything
	    // else is an error.
	    gimple *stmt = gsi_stmt ( outer_gsi);
	    ReorgType_t *ri = contains_a_reorgtype( stmt, info);
	    if ( ri == NULL )
	      {
		//DEBUG_L("No Transfrom on: ");
		//DEBUG_F( print_gimple_stmt, stderr, stmt, 4, TDF_SLIM);
	      }
	    else
	      {
		//DEBUG_F( print_reorg_with_msg, stderr, ri, 0,
		//	 "reorg from str_reorg_instance_interleave_trans");
		
		enum ReorgTransformation trans = 
		  reorg_recognize ( stmt, node, info);
		// print out trans and stmt if dumping
		if ( info->show_transforms )
		  {
		    print_gimple_stmt( info->reorg_dump_file, stmt, 0);
		  }

		switch ( trans)
		  { 
		  case ReorgT_StrAssign:
		    DEBUG_L("ReorgT_StrAssign\n");
		    // TBD
		    /*
	      tree lhs = gimple_assign_lhs( stmt);
	      tree rhs = gimple_assign_rhs( stmt);
	      ReorgOpTrans lope = recognize_op( lhs, info);
	      ReorgOpTrans rope = recognize_op( rhs, info);
	      for each field in ri {
	        // lhs: ReorgT_Array & rhs ReorgT_Struct, ReorgT_Deref, ReorgT_Array
		// lhs: ReorgT_Struct & rhs ReorgT_Deref, ReorgT_Array
		// lhs ReorgT_Deref & rhs ReorgT_Struct, ReorgT_Array, ReorgT_Deref
		A is new ssa
		// Gimple for loading this element
		// Question? What if the element is large? Answer is it's OK.
		switch( rope) {
		// Not implemented in single pool
		//case ReorgT_Array:
		case ReorgT_Struct:
		  generate A <- rhs.field  
		  break;
		case ReorgT_Deref:
		  B,C is new SSA
		  // Note simplification with type_name( rhs)
		  generate B <- concat( REORG_SP_PREFIX, type_name( rhs))
		    and insert before stmt
		  generate C <- B->"f"
		    and insert before stmt
		  generate A <- C[rhs]
		    and insert before stmt
		  break
		default:
		  internal_error(
		    "Reached operand default in RHS enum ReorgOpTrans");
		}
		// Gimple for storing this element
		switch( lope)
		// Not implemented in single pool
		//case ReorgT_Array:
		case ReorgT_Deref:
		  B,C is new SSA
		  // Note simplification with type_name( lhs)
		  generate B <- concat( REORG_SP_PREFIX, type_name( lhs))
		    and insert before stmt
		  generate C <- B->"f"
		    and insert before stmt
		  // lhs here is a simplification
		  generate A <- C[lhs]
		    and insert before stmt
		  break;
		case ReorgT_Struct:
		  generate lhs.field <- A
		  break;
		default:
		  internal_error(
		    "Reached operand default in LHS enum ReorgOpTrans");
		}
	     }
		    */
		    break;
		  case ReorgT_ElemAssign:
		    {
		      //break;
		      gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
		      
		      DEBUG_L("ReorgT_ElemAssign: ");
		      DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
		      INDENT(2);
		      // Needed for helloworld
		      tree lhs = gimple_assign_lhs( stmt);
		      tree rhs = gimple_assign_rhs1( stmt);

		      bool ro_on_left = tree_contains_a_reorgtype_p ( lhs, info);
		      
		      tree ro_side = ro_on_left ? lhs : rhs;
		      tree nonro_side = ro_on_left ? rhs : lhs;
		      
		      switch ( recognize_op ( ro_side, true, info) )  // "a->f"
			{
			case ReorgOpT_Indirect:
			  {
			    tree orig_field = TREE_OPERAND( ro_side, 1);
			    tree field_type = TREE_TYPE( orig_field);
			    tree base = ri->instance_interleave.base;
			    
			    tree base_field =
			      find_coresponding_field ( base, orig_field);
			    
			    tree base_field_type = TREE_TYPE( base_field);

			    gcc_assert ( field_type);
			    tree field_val_temp =
			      make_temp_ssa_name( field_type, NULL, "field_val_temp");

			    tree inner_op = TREE_OPERAND( ro_side, 0);
			    inner_op = TREE_OPERAND( inner_op, 0);
			    //DEBUG_L("inner_op: ");
			    //DEBUG_F( print_generic_expr, stderr, inner_op, (dump_flags_t)0);
			    //DEBUG("\n");
			    
			    // For either case generate common code:
			    
			    // field_array = _base.f
			    gcc_assert ( base_field_type);
			    tree field_arry_addr =
			      make_temp_ssa_name( base_field_type, NULL, "field_arry_addr");

			    tree rhs_faa = build3 ( COMPONENT_REF,
						    // ???
						    base_field_type, 
						    //ptr_type_node, // This seems bogus
						    base,
						    base_field,
						    // This almost certainly is bogus
						    // If this "works" the the types
						    // of fields are messed up.
						    //orig_field,
						    NULL_TREE);

		            // Use this to access the array of element.
			    gimple *get_field_arry_addr =
			      gimple_build_assign( field_arry_addr, rhs_faa);
			    SSA_NAME_DEF_STMT ( field_arry_addr) = get_field_arry_addr;

			    // index = a
			    gcc_assert ( sizetype);
			    tree index =
			      make_temp_ssa_name( sizetype, NULL, "index");
			    gimple *get_index =
			      gimple_build_assign( index, CONVERT_EXPR, inner_op);
			    SSA_NAME_DEF_STMT ( index) = get_index;

			    gimple *temp_set;
			    gimple *final_set;

			    // offset = index * size_of_field
			    tree size_of_field = TYPE_SIZE_UNIT ( base_field_type);
			    gcc_assert ( sizetype);
			    tree offset = make_temp_ssa_name( sizetype, NULL, "offset");

			    gimple *get_offset = gimple_build_assign ( offset, MULT_EXPR, index, size_of_field);
			    SSA_NAME_DEF_STMT ( offset) = get_offset;

			    // field_addr = field_array + offset
			    gcc_assert ( base_field_type);
			    tree field_addr =
			      make_temp_ssa_name( base_field_type, NULL, "field_addr");

			    gimple *get_field_addr = 
			      gimple_build_assign ( field_addr, POINTER_PLUS_EXPR, field_arry_addr, offset);
			    SSA_NAME_DEF_STMT ( field_addr) = get_field_addr;

			    if ( ro_on_left )
			      {
				// With:    a->f = rhs
				// Generate:
				
				//           temp = rhs
				temp_set = gimple_build_assign( field_val_temp, rhs);
				SSA_NAME_DEF_STMT ( field_val_temp) = temp_set;
				
				////           field_array[index] = temp
				//tree elem_to_set =
				//  build4 ( ARRAY_REF, field_type, field_arry_addr, index,
				//	   NULL_TREE, NULL_TREE);
				//final_set =
				//  gimple_build_assign( elem_to_set, field_val_temp);

				//                 *field_addr = temp
				tree lhs_ref = build2 ( MEM_REF, field_type, field_addr,
							build_int_cst (ptr_type_node, 0));
				
				final_set =
				  gimple_build_assign( lhs_ref, field_val_temp);
			      }
			    else
			      {
				// With:    lhs = a->f
				// Generate:
				
				// Tried other idioms here (tricky)
				tree rhs_ref = build2 ( MEM_REF, field_type, field_addr,
							build_int_cst (ptr_type_node, 0));
				

				// If these will actually print then things are likely sane
				//DEBUG_L("rhs_ref: ");
				//DEBUG_F(print_generic_expr, stderr, rhs_ref, (dump_flags_t)0);
				//DEBUG("\n");
				
				tree op0 = TREE_OPERAND ( rhs_ref, 0);
				tree op1 = TREE_OPERAND ( rhs_ref, 1);
				tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1));
				tree op1type_type = TREE_TYPE ( op1type);
				
				temp_set =
				  gimple_build_assign( field_val_temp, rhs_ref);
				SSA_NAME_DEF_STMT ( field_val_temp) = temp_set;
				
				//          lhs = temp
				final_set = gimple_build_assign( lhs, field_val_temp);
				SSA_NAME_DEF_STMT ( lhs) = final_set;
			      }
			    
			    //DEBUG_L("get_field_arry_addr: ");
			    //DEBUG_F( print_gimple_stmt, stderr, get_field_arry_addr, 0);
			    //DEBUG("\n");
			    
			    //DEBUG_L("get_index: ");
			    //DEBUG_F( print_gimple_stmt, stderr, get_index, 0);
			    //DEBUG("\n");

			    //DEBUG_L("get_offset: ");
			    //DEBUG_F( print_gimple_stmt, stderr, get_offset, 0);
			    //DEBUG("\n");

			    //DEBUG_L("get_field_addr: ");
			    //DEBUG_F( print_gimple_stmt, stderr, get_field_addr, 0);
			    //DEBUG("\n");
			    
			    //DEBUG_L("temp_set: ");
			    //DEBUG_F( print_gimple_stmt, stderr, temp_set, 0);
			    //DEBUG("\n");
			    
			    //DEBUG_L("final_set: ");
			    //DEBUG_F( print_gimple_stmt, stderr, final_set, 0);
			    //DEBUG("\n");

			    gsi_insert_before( &gsi, get_field_arry_addr, GSI_SAME_STMT);
			    gsi_insert_before( &gsi, get_index, GSI_SAME_STMT);
			    gsi_insert_before( &gsi, get_offset, GSI_SAME_STMT);
			    gsi_insert_before( &gsi, get_field_addr, GSI_SAME_STMT);
			    gsi_insert_before( &gsi, temp_set, GSI_SAME_STMT);
			    gsi_insert_before( &gsi, final_set, GSI_SAME_STMT);
			    
			      
			    //delete stmt
			    gsi_remove ( &gsi, true);
			  } // end ReorgOpT_Indirect case
			  break;
			case ReorgOpT_AryDir:  // "x[i].f"
			  // Not implemented in single pool
			  internal_error ( "ReorgOpT_AryDir not possible");
			default:
			  internal_error (
					  "Reached operand default for ReorgOpT_Indirect");
			  
			} // end recognize_op ( rhs, info) switch

		      INDENT(-2);
		    } // end ReorgT_ElemAssign case
		    break;
		  case ReorgT_If_Null:
		  case ReorgT_If_NotNull:
		    {
		      DEBUG_L("ReorgT_If_(Not)Null: ");
		      DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
		      /*
			gimple_cond_set_rhs( stmt, 
			TYPE_MAX_VALUE( pointer_sized_int_node));
		      */
		      // TYPE_MAX_VALUE ( TREE_TYPE ( fail_val)
		      gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
		      ReorgType_t *ri = contains_a_reorgtype( stmt, info);
		      //tree null_val = 
		      //  make_temp_ssa_name ( ri->pointer_rep, NULL, "if_cond_null");
		      gcond *cond_stmt = as_a <gcond *> (stmt);
		      
		      //tree max = TYPE_MAX_VALUE ( TREE_TYPE ( ri->pointer_rep));
		      tree max = TYPE_MAX_VALUE ( ri->pointer_rep);
		      
		      DEBUG_L("max: ");
		      DEBUG_F(print_generic_expr, stderr, max, (dump_flags_t)0);
		      DEBUG("\n");
		      
		      gimple_cond_set_rhs( cond_stmt, max);
		      
		      DEBUG_L("after: ");
		      DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
		    }
		    break;
		  case ReorgT_IfPtrEQ:
		  case ReorgT_IfPtrNE:
		  case ReorgT_IfPtrLT:
		  case ReorgT_IfPtrGT:
		  case ReorgT_IfPtrLE:
		  case ReorgT_IfPtrGE:
		    DEBUG_L("ReorgT_IfPtr*\n");
		    // Not needed for single pool. TBD test this
		    break;
		  case ReorgT_PtrPlusInt:   // "a = b + i"
		    {
		      DEBUG_L("ReorgT_PtrPlusInt: ");
		      DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
		      // Needed for hellowotrld
		      
		      // Does the type of stmt need to be adjusted? I assume so.
		      // The ReorgType contains the type of the pointer
		      // if so that should probably be used. Note, the variables
		      // should all be of the correct type (but maybe that's
		      // not reflected here. Punting and assigning the types to
		      // the type of pointer_sized_int_node is probably not correct
		      // even though that's the representation.

		      tree PPI_orig_lhs = gimple_assign_lhs ( stmt);

		      //tree offset_type = TREE_TYPE ( TYPE_SIZE_UNIT (ri->gcc_type)); // not needed
		      tree type = ri->pointer_rep;

		      tree str_siz =
			build_int_cst ( type, int_cst_value ( TYPE_SIZE_UNIT (ri->gcc_type)));
		      
		      tree rhs1 = gimple_assign_rhs1( stmt);
		      tree rhs2 = gimple_assign_rhs2( stmt);

		      gcc_assert ( type);
		      tree PPI_rhs1_cast = make_temp_ssa_name( type, NULL, "PPI_rhs1_cast");
		      gimple *gPPI_rhs1_cast = gimple_build_assign ( PPI_rhs1_cast, CONVERT_EXPR, rhs1);
		      SSA_NAME_DEF_STMT ( PPI_rhs1_cast) = gPPI_rhs1_cast;
		      
		      tree PPI_rhs2_cast = make_temp_ssa_name( type, NULL, "PPI_rhs2_cast");
		      gimple *gPPI_rhs2_cast = gimple_build_assign ( PPI_rhs2_cast, CONVERT_EXPR, rhs2);
		      SSA_NAME_DEF_STMT ( PPI_rhs2_cast) = gPPI_rhs2_cast;

		      tree PPI_adj =  make_temp_ssa_name( type, NULL, "PtrPlusInt_Adj");
		      gimple *gPPI_adj =
			gimple_build_assign ( PPI_adj, TRUNC_DIV_EXPR, PPI_rhs2_cast, str_siz);
		      SSA_NAME_DEF_STMT ( PPI_adj) = gPPI_adj;

		      tree ptrplusint =  make_temp_ssa_name( type, NULL, "PtrPlusInt");
		      gimple *gPPI =
		      	gimple_build_assign ( ptrplusint, PLUS_EXPR, PPI_rhs1_cast, PPI_adj);
		      SSA_NAME_DEF_STMT ( ptrplusint) = gPPI;
		      
		      gimple *gPPI_cast = 
			gimple_build_assign ( PPI_orig_lhs, CONVERT_EXPR, ptrplusint);
		      SSA_NAME_DEF_STMT ( PPI_orig_lhs) = gPPI_cast;
		      
		      //gimple_set_op( stmt, 2, tmp);
		      gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
		      gsi_insert_before( &gsi, gPPI_rhs1_cast, GSI_SAME_STMT);
		      gsi_insert_before( &gsi, gPPI_rhs2_cast, GSI_SAME_STMT);
		      gsi_insert_before( &gsi, gPPI_adj, GSI_SAME_STMT);
		      gsi_insert_before( &gsi, gPPI, GSI_SAME_STMT);
		      gsi_insert_before( &gsi, gPPI_cast, GSI_SAME_STMT);

		      gsi_remove ( &gsi, true);

		      DEBUG_L("");
		      DEBUG_F( print_gimple_stmt, stderr, gPPI_rhs2_cast, 0);
		      DEBUG_L("");
		      DEBUG_F( print_gimple_stmt, stderr, gPPI_adj, 0);
		      DEBUG_L("");
		      DEBUG_F( print_gimple_stmt, stderr, gPPI, 0);
		      DEBUG_L("");
		      DEBUG_F( print_gimple_stmt, stderr, gPPI_cast, 0);
		    }
		    break;
		  case ReorgT_Ptr2Zero:   //  "a = 0"
		    DEBUG_L("ReorgT_Ptr2Zero\n");
		    /*
		    // TBD
		    // Note, this is way too simple... just saying.
		    gimple_set_op( stmt, 1, 
		    TYPE_MIN_VALUE( pointer_sized_int_node));
		    */
		    break;
		  case ReorgT_PtrDiff:    //  "i = a - b"
		    {
		      DEBUG_L("ReorgT_PtrDiff\n");
		      // We basically need to modify the gimple code
		      // but that also means adding converts.
		      tree type = ri->pointer_rep;
		      tree str_siz =
			build_int_cst ( type, int_cst_value ( TYPE_SIZE_UNIT (ri->gcc_type)));
		      tree rhs1 = gimple_assign_rhs1( stmt);
		      tree rhs2 = gimple_assign_rhs2( stmt);
		      tree PD_orig_lhs = gimple_assign_lhs ( stmt);
		      
		      tree PD_rhs1_cast = make_temp_ssa_name( type, NULL, "PD_rhs1_cast");
		      gimple *gPD_rhs1_cast = gimple_build_assign ( PD_rhs1_cast, CONVERT_EXPR, rhs1);
		      SSA_NAME_DEF_STMT ( PD_rhs1_cast) = gPD_rhs1_cast;
		      
		      tree PD_rhs2_cast = make_temp_ssa_name( type, NULL, "PD_rhs2_cast");
		      gimple *gPD_rhs2_cast = gimple_build_assign ( PD_rhs2_cast, CONVERT_EXPR, rhs2);
		      SSA_NAME_DEF_STMT ( PD_rhs2_cast) = gPD_rhs2_cast;
		      
		      tree ptrdiff =  make_temp_ssa_name( type, NULL, "PtrDiff");
		      gimple *gPD =
		      	gimple_build_assign ( ptrdiff, MINUS_EXPR, PD_rhs1_cast, PD_rhs2_cast);
		      SSA_NAME_DEF_STMT ( ptrdiff) = gPD;

		      tree PD_adjust =  make_temp_ssa_name( type, NULL, "PD_adjust");
		      gimple *gPD_adjust =
			gimple_build_assign ( PD_adjust, MULT_EXPR, ptrdiff, str_siz);

		      gimple *gPD_cast = 
			gimple_build_assign ( PD_orig_lhs, CONVERT_EXPR, PD_adjust);
		      SSA_NAME_DEF_STMT ( PD_orig_lhs) = gPD_cast;
		      
		      gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
		      gsi_insert_before( &gsi, gPD_rhs1_cast, GSI_SAME_STMT);
		      gsi_insert_before( &gsi, gPD_rhs2_cast, GSI_SAME_STMT);
		      gsi_insert_before( &gsi, gPD, GSI_SAME_STMT);
		      gsi_insert_before( &gsi, gPD_adjust, GSI_SAME_STMT);
		      gsi_insert_before( &gsi, gPD_cast, GSI_SAME_STMT);

		      gsi_remove ( &gsi, true);

		      DEBUG_L("");
		      DEBUG_F( print_gimple_stmt, stderr, gPD_rhs1_cast, 0);
		      DEBUG_L("");
		      DEBUG_F( print_gimple_stmt, stderr, gPD_rhs2_cast, 0);
		      DEBUG_L("");
		      DEBUG_F( print_gimple_stmt, stderr, gPD, 0);
		      DEBUG_L("");
		      DEBUG_F( print_gimple_stmt, stderr, gPD_cast, 0);
		  }
		    break;
		  case ReorgT_Adr2Ptr:    //  "a = &x[i]"
		    DEBUG_L("ReorgT_Adr2Ptr\n");
		    // TBD
		    /*
	      tree *add_stmt = 
	        gimple_build_assign( 
        	  gimple_assign_lhs( stmt);, 
		  PLUS_EXPR, 
		  gimple_assign_rhs1( stmt), 
		  gimple_assign_rhs2( stmt), 
		  NULL_TREE, NULL_TREE);
	      gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
	      gsi_insert_before( gsi, add_stmt, GSI_SAME_STMT);
	      // delete stmt
	      gsi_remove( gsi, true);
		    */
		    break;
		  case ReorgT_PtrNull:     //  "x = a == 0"
		  case ReorgT_PtrNotNull:  //  "x = a != 0"
		    DEBUG_L("ReorgT_Ptr(Not)Null\n");\
		    // TBD
		    /*
	      gimple_set_op( stmt, 2, 
	      		     TYPE_MIN_VALUE( pointer_sized_int_node));
		    */
		    break;
		  case ReorgT_PtrEQ:       //  "i = a == b"
		  case ReorgT_PtrNE:       //  "i = a != b"
		  case ReorgT_PtrLT:       //  "i = a < b"
		  case ReorgT_PtrLE:       //  "i = a <= b"
		  case ReorgT_PtrGT:       //  "i = a > b"
		  case ReorgT_PtrGE:       //  "i = a >= b"
		    DEBUG_L("ReorgT_Ptr*\n");
		    // Not needed for single pool. TBD test this
		    break;
		  case ReorgT_Malloc:
		    {
		      DEBUG_L("Transform ReorgT_Malloc\n");
		      INDENT(2);

		      // We need to use the user malloc function
		      // declaration rather than the builtin!!!
		      tree fndecl_malloc = gimple_call_fndecl ( stmt);
		      
		      // We need to synthesize the free function
		      //
		      tree param_type_list = NULL;
		      tree void_pointer_type_node = build_pointer_type ( void_type_node);
		      param_type_list =
			tree_cons ( NULL_TREE, void_pointer_type_node, param_type_list);
		      //DEBUG_L("param_type_list: ");
		      //DEBUG_F(print_generic_expr, stderr, param_type_list, (dump_flags_t)0);
		      //DEBUG("\n");
		      #if !USE_BUILT_IN_FREE
		      tree free_return_type = void_type_node;
		      #endif
		      //DEBUG_L("free_return_type: ");
		      //DEBUG_F(print_generic_expr, stderr, free_return_type, (dump_flags_t)0);
		      //DEBUG("\n")
		      #if USE_BUILT_IN_FREE
		      tree fndecl_free = builtin_decl_implicit ( BUILT_IN_FREE);
		      #else
		      tree fntype = build_function_type ( free_return_type, param_type_list);
		      tree fnname = get_identifier ( "free");
		      tree fndecl_free = build_decl ( input_location, FUNCTION_DECL, fnname, fntype);
		      #endif
		      // Note, add it to the call graph at each call site
		      
		      // Note, unlike other simpler transformations,
		      // this must build new basic blocks to add new
		      // gimple to and use a phi for the final result.
		      // See appendix on malloc transformation for
		      // each comment starting with "FROM."
		      ReorgType_t *ri = contains_a_reorgtype( stmt, info);
		      // FROM len = val/size
		      tree arg = gimple_call_arg( stmt, 0);
		      // TBD: len is new SSA
		      tree val = gimple_call_lhs( stmt);
		      //DEBUG_L("val is: ");
		      //DEBUG_F( print_generic_expr, stderr, val, (dump_flags_t)-1);
		      //DEBUG(", tree code type: %s\n", code_str(TREE_CODE(TREE_TYPE(val))));
		      //gcc_assert( TREE_CODE( TREE_TYPE(val)) == INDIRECT_REF);
		      gcc_assert( TREE_CODE( TREE_TYPE(val)) == POINTER_TYPE);
		      tree size = TYPE_SIZE_UNIT( TREE_TYPE( TREE_TYPE( val)));
		      // FROM len = val/size (insert before stmt) <== maybe arg/size
		      //tree len = make_temp_ssa_name( sizetype, NULL, "fail_val");
		      // The above segfaulted ??? note, it's not an idiom seen in gcc
		      tree int_ptrsize_type = signed_type_for ( ptr_type_node);
		      //DEBUG_L("int_ptrsize_type = %p\n", TREE_TYPE ( size));
		      gcc_assert ( TREE_TYPE ( size));
		      tree len = make_temp_ssa_name ( TREE_TYPE ( size), NULL, "malloc_len");
		      gimple_stmt_iterator gsi = gsi_for_stmt( stmt);
		      //gimple *glen = 
		      //  gimple_build_assign ( len, TRUNC_DIV_EXPR, val, size);

		      // Cast arg to compatible type
		      gcc_assert( TREE_TYPE ( size));
		      TREE_TYPE (arg) = TREE_TYPE ( size);
		      tree cast_arg =
			    make_temp_ssa_name( TREE_TYPE ( size), NULL, "cast_arg");
		      gimple *gcast_arg = gimple_build_assign ( cast_arg, CONVERT_EXPR, arg);
		      SSA_NAME_DEF_STMT ( cast_arg) = gcast_arg;
		      gsi_insert_before( &gsi, gcast_arg, GSI_SAME_STMT);
			
		      gimple *glen = 
			gimple_build_assign ( len, TRUNC_DIV_EXPR, cast_arg, size);
		      SSA_NAME_DEF_STMT ( len) = glen;
		      
		      gsi_insert_before( &gsi, glen, GSI_SAME_STMT);
		      // Note in other places in this doc this would
		      // be "insert glen before stmt" instead of this but
		      // here we need to create new basic blocks.
		      edge new_edge = split_block ( bb, stmt);
		      // FROM before_bb = edge->src // same as this bb
		      basic_block before_bb = new_edge->src; // 
		      basic_block after_bb = new_edge->dest;
		      remove_edge ( new_edge);
		      basic_block prev_bb = before_bb;
		      
		      // FROM failure_bb = create_empty_block(prev_bb)
		      basic_block failure_bb = make_bb ( "failure_bb", prev_bb);
		      // I need to set the count to zero and there doesn't
		      // seem to be direct way of doing this...
		      failure_bb->count = prev_bb->count - prev_bb->count;
		      
		      // set edge probability and flags
		      edge fail_to_after_e = make_edge ( failure_bb,
						      after_bb, EDGE_FALLTHRU);
		      fail_to_after_e->probability = profile_probability::very_unlikely ();
		      fail_to_after_e->count () = failure_bb->count;

		      // Note, this should remove this call from the call graph
		      cgraph_update_edges_for_call_stmt ( stmt, gimple_call_fndecl ( stmt), NULL);
		      // Now it's safe to remove it!
		      gsi_remove ( &gsi, true);
		      
		      tree field;
		      tree reorg_type = ri->gcc_type; // is this useful here?
		      tree reorg_pointer_type = ri->pointer_rep;
		      //tree base = ri->reorg_ver_type; //nopers
		      tree base = ri->instance_interleave.base;

		      // ??? We are faking the malloc so the following seemed dubious
		      //tree malloc_return_type = TREE_TYPE ( arg);
		      //tree fail_val = 
		      //	make_temp_ssa_name ( malloc_return_type, NULL, "malloc_fail_val");
		      gcc_assert ( reorg_pointer_type);
		      tree fail_val = 
		      	make_temp_ssa_name ( reorg_pointer_type, NULL, "malloc_fail_val");
		      
		      // loop setup trickery for gimple idioms
		      //
		      // FROM prev_order = failure_bb
		      basic_block prev_order = failure_bb;
		      // FROM prev_bb = before_bb
		      prev_bb = before_bb;
		      int edge_flags = EDGE_FALLTHRU;
		      
		      // Generate all the real allocation code
		      //
		      // Note, I think there are ramifications of built in malloc (and free)
		      // so I'm going try and use the malloc in the call transformed!!!
		      // Actually, I ended up using the built in free and it was
		      // the way to go.
		      //
		      
		      //tree fndecl_malloc = builtin_decl_explicit( BUILT_IN_MALLOC);
		      
		      // This, after the following loop, will hold the start of the
		      // field related code.
		      tree new_ok_field_L;
		      
		      // FROM (for fields) {
		      bool first = true;
		      for( field = TYPE_FIELDS( reorg_type); 
			   field; 
			   field = DECL_CHAIN( field))
			{
			  basic_block new_bb = make_bb ( "new_bb", prev_order);
			  new_bb->count = prev_order->count;
			  // Nope! Don't do this.
			  //set_immediate_dominator ( CDI_DOMINATORS, new_bb, prev_bb);
			  //if ( first )
			  //  {
			  //    first = false;
			  //    set_immediate_dominator ( CDI_DOMINATORS, failure_bb, new_bb);
			  //    set_immediate_dominator ( CDI_DOMINATORS, after_bb, new_bb);
			  //  }
			    
			  tree base_field =
			      find_coresponding_field ( base, field);

			  //DEBUG_L("base_field: %p\n", base_field);
			  //DEBUG_A("  : ");
			  //DEBUG_F(print_generic_expr, stderr, base_field, (dump_flags_t)0);
			  //DEBUG("\n");

			  tree base_field_type = TREE_TYPE( base_field);
			  //DEBUG_L("base_field_type: %p\n", base_field_type);
			  //DEBUG_A("  : ");
			  //DEBUG_F(print_generic_expr, stderr, base_field_type, (dump_flags_t)0);
			  //DEBUG("\n");
			  
			  gimple_stmt_iterator gsi = gsi_start_bb ( new_bb);
			  // Note, switching the order of edge creation and
			  // setting dominator seems to make no difference
			  
			  // set edge probability and flags
			  
			  // edge_flags depends on whether or not the predecessor
			  // block was created in this loop.
			  edge ok_edge = make_edge ( prev_bb, new_bb, edge_flags);
			  edge_flags = EDGE_TRUE_VALUE;

			  ok_edge->probability = profile_probability::very_likely ();
			  ok_edge->count () = prev_bb->count;
			  add_bb_to_loop ( new_bb, before_bb->loop_father);
			  
			  // Don't mess with the dominators.
			  //set_immediate_dominator ( CDI_DOMINATORS, new_bb, prev_bb);

			  // create edge and set edge probability and flags
			  edge fail_edge = make_edge ( new_bb, failure_bb, EDGE_FALSE_VALUE);
			  fail_edge->probability = profile_probability::very_unlikely ();
			  fail_edge->count () = new_bb->count - new_bb->count;

			  //tree lhs_ass =
			  //  build3( COMPONENT_REF, ptr_type_node, base, field, NULL_TREE);
			  tree lhs_ass = build3( COMPONENT_REF,
						 base_field_type,
						 base,
						 base_field, NULL_TREE);

			  //DEBUG_L("base: %p\n", base);
			  //DEBUG_A("  base: ");
			  //DEBUG_F(print_generic_expr, stderr, base, (dump_flags_t)0);
			  //DEBUG("\n");
			  
			  //DEBUG_L("field: %p\n", field);
			  //DEBUG_A("  : ");
			  //DEBUG_F(print_generic_expr, stderr, field, (dump_flags_t)0);
			  //DEBUG("\n");

			  tree field_type = TREE_TYPE( field);
			  //DEBUG_L("field_type: %p\n", field_type);
			  //DEBUG_A("  : ");
			  //DEBUG_F(print_generic_expr, stderr, field_type, (dump_flags_t)0);
			  //DEBUG("\n");
			  
			  //DEBUG_L("lhs_ass: %p\n", lhs_ass);
			  //DEBUG_A("  lhs_ass: ");
			  //DEBUG_F(print_generic_expr, stderr, lhs_ass, (dump_flags_t)0);
			  //DEBUG("\n");

			  tree lhs_ass_type = TREE_TYPE ( lhs_ass);
			  //DEBUG_L("lhs_ass_type: %p\n", lhs_ass_type);
			  //DEBUG_A("  lhs_ass_type: ");
			  //DEBUG_F(print_generic_expr, stderr, lhs_ass_type, (dump_flags_t)0);
			  //DEBUG("\n");

			  gcc_assert ( sizetype);
			  tree mem_size = 
			    make_temp_ssa_name( sizetype, NULL, "malloc_mem_size");
			  
			  // We need field_size to be of the correct type so
			  // we type cast.
			  gcc_assert ( TREE_TYPE ( mem_size));
			  tree field_size =
			    make_temp_ssa_name( TREE_TYPE ( mem_size), NULL, "field_size");

			  // Move gprev_ok_field here
			  
			  // Move gfield_size here
			  gimple *gfield_size =
			    gimple_build_assign ( field_size,
						  CONVERT_EXPR,
						  TYPE_SIZE ( TREE_TYPE ( field)));
			  SSA_NAME_DEF_STMT ( field_size) = gfield_size;

			  // Move gsize here
			  gimple *gsize = 
			    gimple_build_assign ( mem_size,
						  MULT_EXPR,
						  field_size,
						  len);
			  SSA_NAME_DEF_STMT ( mem_size) = gsize;

			  gcc_assert ( ptr_type_node);
			  tree res = 
			    make_temp_ssa_name ( ptr_type_node, NULL, "res");

			  gcc_assert ( TREE_TYPE ( base_field));
			  tree cast_res =
			    make_temp_ssa_name ( TREE_TYPE ( base_field), NULL, "cast_res");

			  tree res_type = TREE_TYPE( res);
			  //DEBUG_L("res_type: %p\n", res_type);
			  //DEBUG_A("  : ");
			  //DEBUG_F(print_generic_expr, stderr, res_type, (dump_flags_t)0);
			  //DEBUG("\n");

			  // Move malloc_call here
			  gcall *malloc_call = gimple_build_call( fndecl_malloc, 1, mem_size);
			  gimple_call_set_lhs( malloc_call, res);
			  SSA_NAME_DEF_STMT ( res) = malloc_call;

			  cgraph_node::get ( cfun->decl)->
			    create_edge ( cgraph_node::get_create ( fndecl_malloc),
					  malloc_call,
					  // Nah... lets do this a bit differently
					  //gimple_bb ( free_call)->count
					  new_bb->count
					  );
			  
			  gimple *gcast_res =
			    gimple_build_assign ( cast_res, CONVERT_EXPR, res);
			  SSA_NAME_DEF_STMT ( cast_res) = gcast_res;
			  
			  // Move gset_field here
			  gimple *gset_field = gimple_build_assign ( lhs_ass, cast_res);

			  // Move gcond here
			  gimple *gcond =
			    gimple_build_cond ( NE_EXPR, res, null_pointer_node,
						NULL, NULL
						);

			  // In execution order
			  gsi_insert_after ( &gsi, gfield_size, GSI_NEW_STMT);
			  gsi_insert_after ( &gsi, gsize, GSI_CONTINUE_LINKING);
			  gsi_insert_after ( &gsi, malloc_call, GSI_CONTINUE_LINKING);
			  gsi_insert_after ( &gsi, gcast_res, GSI_CONTINUE_LINKING);
			  gsi_insert_after ( &gsi, gset_field, GSI_CONTINUE_LINKING);
			  gsi_insert_after ( &gsi, gcond, GSI_CONTINUE_LINKING);
			  
			  prev_bb = new_bb;
			  prev_order = new_bb;
			}

		      // Loop cleaup fo failure code bb here. There is loop state
		      // overhead having nothing to do with the transformation
		      // that never the less must be updated.
		      add_bb_to_loop ( failure_bb, before_bb->loop_father);
		      
		      // create basic block for success
		      //
		      // FROM success_bb = create_empty_block(prev_bb_order);
		      basic_block success_bb = make_bb ( "succ_bb", prev_bb);
		      success_bb->count = prev_bb->count;
		      
		      // NOTE, it seems I shouldn't be attempting
		      // to diddle the dominator information on the fly.
		      // set_immediate_dominator ( CDI_DOMINATORS, success_bb, prev_bb);
		      
		      edge success_e = make_edge ( prev_bb, success_bb, EDGE_TRUE_VALUE );
		      edge succ_to_after_e = make_edge ( success_bb, after_bb, EDGE_FALLTHRU);
		      success_e->probability = profile_probability::very_likely ();
		      succ_to_after_e->probability = profile_probability::always ();
		      success_e->count () = prev_bb->count;
		      succ_to_after_e->count () = prev_bb->count;
		      add_bb_to_loop ( success_bb, before_bb->loop_father);
		      
		      // code in success_bb
		      //
		      gcc_assert ( reorg_pointer_type);
		      tree success_val = 
			make_temp_ssa_name( reorg_pointer_type, NULL, "malloc_success_val");

		      gsi = gsi_start_bb ( success_bb);  // used to be failure_bb

		      gimple *set_succ =
			gimple_build_assign ( success_val,
					      build_int_cst ( reorg_pointer_type, 0));
		      SSA_NAME_DEF_STMT ( success_val) = set_succ;
		      
		      gsi_insert_after( &gsi, set_succ,	GSI_NEW_STMT);

		      // FROM gsi_insert_after( &gsi, new_ok_field )
		      //gimple *gnew_ok_field = gimple_build_label ( new_ok_field_L);
		      //gsi_insert_after ( &gsi, gnew_ok_field, GSI_SAME_STMT);
		      
		      // add code to after_bb
		      //
		      // FROM gsi = gsi_start_bb( after_bb)
		      // Reuse gsi
		      //gimple_stmt_iterator gsi = gsi_start_bb( after_bb);
		      gsi = gsi_start_bb( after_bb);

		      // FROM gsi_insert_after( &gsi, "lhs = "phi(success_val, fail_val)
		      
		      // Note, BBs have a sequence of phis which create_phi_node takes care of
		      // adding this phi too.
		      gcc_assert ( TREE_TYPE ( success_val));
		      tree m_phi_val =
			make_temp_ssa_name ( TREE_TYPE ( success_val), NULL, "m_phi_val");
		      gphi *der_phi = create_phi_node( m_phi_val, after_bb);
		      add_phi_arg( der_phi, success_val, succ_to_after_e, UNKNOWN_LOCATION);
		      add_phi_arg( der_phi, fail_val, fail_to_after_e, UNKNOWN_LOCATION);

		      gimple *gm_cast_phi_val =
			gimple_build_assign ( val, CONVERT_EXPR, m_phi_val);
		      SSA_NAME_DEF_STMT ( val) = gm_cast_phi_val;

		      //gsi_insert_after( &gsi, gm_cast_phi_val, GSI_NEW_STMT);
		      // TBD What does GSI_NEW_STMT do if  the block isn't emply?
		      gsi_insert_before( &gsi, gm_cast_phi_val, GSI_NEW_STMT);

		      //// FROM gsi_insert_after( &gsi, after_label)
		      //gimple *gafter_label = gimple_build_label( after_label_L);
		      //gsi_insert_after( &gsi, gafter_label, GSI_SAME_STMT);


		      // failure_bb code here

		      //
		      // FROM fail_val is new SSA
		      //tree return_type = TREE_TYPE ( arg);
		      //tree fail_val = 
		      //  make_temp_ssa_name ( return_type, NULL, "fail_val");
		      // FROM gsi = gsi_start_bb ( failure_bb)
		      gsi = gsi_start_bb ( failure_bb);

		      // FROM gsi_insert_after( &gsi, "fail_val = minint")
		      gimple *gretnull =
			gimple_build_assign ( fail_val, CONVERT_EXPR,
					      TYPE_MAX_VALUE ( TREE_TYPE ( fail_val)));
		      SSA_NAME_DEF_STMT ( fail_val) = gretnull;
		      
		      gsi_insert_after( &gsi, gretnull, GSI_NEW_STMT);
		      
		      for( field = TYPE_FIELDS( reorg_type); 
			   field; 
			   field = DECL_CHAIN( field)) {

			tree base_field =
			      find_coresponding_field ( base, field);
			tree base_field_type = TREE_TYPE( base_field);
			
			gcc_assert ( base_field_type);
			tree m_to_free = 
			  make_temp_ssa_name( base_field_type, NULL, "malloc_to_free");
			
			tree rhs_ass = build3( COMPONENT_REF,
			    base_field_type,
			    base,
			    base_field, NULL_TREE);
			
			gimple *gaddr2free = gimple_build_assign( m_to_free, rhs_ass);
			SSA_NAME_DEF_STMT ( m_to_free) = gaddr2free;
			
			gsi_insert_after( &gsi, gaddr2free, GSI_CONTINUE_LINKING);

			gcc_assert ( ptr_type_node);
			tree m_cast2free =
			  make_temp_ssa_name( ptr_type_node, NULL, "m_cast2free");
			
			gimple *gm_cast2free =
			  gimple_build_assign( m_cast2free, CONVERT_EXPR, m_to_free);
			SSA_NAME_DEF_STMT ( m_cast2free) = gm_cast2free;

			gsi_insert_after( &gsi, gm_cast2free, GSI_CONTINUE_LINKING);
			
			gcall *free_call = gimple_build_call( fndecl_free, 1, m_cast2free);
			gsi_insert_after( &gsi, free_call, GSI_CONTINUE_LINKING);
			
			cgraph_node::get ( cfun->decl)->
			create_edge ( cgraph_node::get_create ( fndecl_free),
				      free_call,
				      failure_bb->count
				    );

			tree lhs_ass = build3( COMPONENT_REF,
					       base_field_type,
					       base,
					       base_field, NULL_TREE);
			
			gimple *gzero = gimple_build_assign( lhs_ass, null_pointer_node);
			gsi_insert_after( &gsi, gzero, GSI_CONTINUE_LINKING);
		      }
		      
		      //// FROM gsi_insert_after( &gsi, bad_field )

		      //DEBUG_L("End of malloc:\n");
		      //DEBUG_F( print_program, PRINT_FORMAT, stderr, 4);
		    }
		    INDENT(-2);
		    break;
		  case ReorgT_Calloc:
		    // TBD
		    DEBUG_L("ReorgT_Calloc\n");
		    /*
		    // This used to be almost a clone of the old version of
		    // the malloc code above and needs to transformed just like
		    // what was done above to malloc.
		    tree arg = gimple_call_arg( stmt, 0);
		    len is new SSA
		      tree val = gimple_call_lhs( stmt);
		    gcc_assert( TREE_CODE( TREE_TYPE(val)) == INDIRECT_REF);
		    tree size = TYPE_SIZE_UNIT( TREE_TYPE( TREE_TYPE( val)));
		    gimple *glen = 
		      gimple_build_assign( 
					  len, 
					  TRUNC_DIV_EXPR, 
					  val, 
					  size,
					  NULL_TREE, NULL_TREE);
		    //insert glen before stmt
		    gimple_stmt_iterator stmt_gsi = gsi_for_stmt ( stmt);
		    gsi_link_before( stmt_gsi, glen, GSI_SAME_STMT);
		    tree lfial = create_artificial_label( UNKNOWN_LOCATION);
		    gimple *gfail = gimple_build_label( lfail);
		    tree lnotfial = create_artificial_label( UNKNOWN_LOCATION);
		    gimple *gnotfail = gimple_build_label( lnotfail);
		    tree base = ri->reorg_ver_type;
		    for (each element of base) // TBD <==
		      {
			// call malloc
			tree lok = create_artificial_label( UNKNOWN_LOCATION);
			gimple *glok = gimple_build_label( lok);
			tree *fndecl = builtin_decl_explicit( BUILT_IN_MALLOC);
			mem_size is new SSA
			  gimple *gsize = 
			  gimple_build_assign( 
					      mem_size, 
					      MULT_EXPR, 
					      TYPE_SIZE(element), 
					      len,
					      NULL_TREE, NULL_TREE);
			insert gsize before stmt
			  gcall *call = gimple_build_call( fndecl, 1, mem_size);
			mres is new SSA
			  gimple_call_set_lhs( call, mres)
			  insert call before stmt
			  // Set element to return value of malloc.
			  // Note, the devil is in the details here.
			  gen concat( REORG_SP_PREFIX,
				      type_name( lhs)  ).element <- mres
			  and insert before stmt
			  // gen test of return
			  gimple *gcond =
			  gimple_build_cond( EQ_EXPR, mres,
					     null_pointer_node, lfail, lok);
			insert gcond before stmt
			  insert glok before stmt
			  // call memset
			  fndecl = builtin_decl_explicit( BUILT_IN_MEMSET);
			call =
			  gimple_build_call( fndecl, 3, mres, int_node_zero, mem_size);
			insert call before stmt
			  }
	      
		    // fake return value of zero
		    gimple *gretzero =
		      gimple_build_assign( lhs,
					   build_int_cst(
							 TYPE_MIN_VALUE( TREE_TYPE(lhs)), 0));
		    insert gretzero before stmt
		      gimple *ggoto = gimple_build_goto( lnotfail);
		    insert ggoto before stmt
		      insert glab1 before stmt
		      for each element of base {
			  tree fndecl = builtin_decl_explicit( BUILT_IN_FREE);
			  gcall *call = gimple_build_call( fndecl, 1, element);
			  insert call before stmt
			    set element to null
			    }
		    // fake return value of null
		    gimple *gretnull =
		      gimple_build_assign( lhs,
					   build_int_cst(
							 TYPE_MIN_VALUE( TREE_TYPE(lhs))));
		    insert gretnull before stmt
		      insert gnotfail before stmt
		      delete stmt
		      */
		    break;
		  case ReorgT_Realloc:
		    // TBD
		    DEBUG_L("ReorgT_Realloc\n");
		    /*
		// This used to be closely related to the old version of
		// the malloc code above and needs to transformed just like
		// what was done above to malloc.
		tree arg = gimple_call_arg( stmt, 0);
		len is new SSA
		tree val = gimple_call_lhs( stmt);
		gcc_assert( TREE_CODE( TREE_TYPE(val)) == INDIRECT_REF);
		tree size = TYPE_SIZE_UNIT( TREE_TYPE( TREE_TYPE( val)));
		gimple *glen = 
	        gimple_build_assign( 
		  len, 
		  TRUNC_DIV_EXPR, 
		  val, 
		  size,
		  NULL_TREE, NULL_TREE);
		insert glen before stmt
		tree lfial = create_artificial_label( UNKNOWN_LOCATION);
		gimple *gfail = gimple_build_label( lfail);
		tree lnotfial = create_artificial_label( UNKNOWN_LOCATION);
		gimple *gnotfail = gimple_build_label( lnotfail);
		for each field of base {
	      	  // call malloc
		  tree lok = create_artificial_label( UNKNOWN_LOCATION);
		  gimple *gok = gimple_build_label( lok);
		  tree fndecl = builtin_decl_explicit( BUILT_IN_REALLOC);
		  // but first compute how much to malloc
		  mem_size, var, ptr are new SSA
		  gimple *gsize = 
	          gimple_build_assign( 
        	    mem_size, 
		    MULT_EXPR, 
		    TYPE_SIZE(field), 
		    len,
		    NULL_TREE, NULL_TREE);
		  insert gsize before stmt
		  generate ptr = base.field & insert before stmt
		  gcall *call
		    = gimple_build_call( fndecl, 3, ptr,
		    		         len, TYPE_SIZE( field));
		  gimple_call_set_lhs( call, var);
		  insert call before stmt
		  // gen test of return
		  gimple *gcond =
		  gimple_build_cond( EQ_EXPR, var,
		  null_pointer_node, lfail, lok);
		  insert gcond before stmt
		  insert gok before stmt
		  generate base.field = var & insert before stmt
		}
		// fake return value of starting address (an index of zero)
		gimple *gretzero =
	          gimple_build_assign( lhs, //
		    build_int_cst(
		    TYPE_MIN_VALUE( TREE_TYPE(lhs)), 0));
		insert gretzero before stmt
		gimple *ggoto = gimple_build_goto( lnotfail);
		insert ggoto before stmt
		insert glab1 before stmt
		for each element of base {
	      	tree fndecl = builtin_decl_explicit( BUILT_IN_FREE);
	        gcall *call = gimple_build_call( fndecl, 1, element);
		insert call before stmt
		set element to null
	      }
	      // fake return value of null (minimum value under this scheme)
	      gimple *gretnull =
	        gimple_build_assign( lhs,
				     build_int_cst(
				       TYPE_MIN_VALUE( TREE_TYPE(lhs))));
	      insert gretnull before stmt
	      insert gnotfail before stmt
	      delete stmt
		    */
		    break;
		  case ReorgT_Free:
		    // TBD
		    DEBUG_L("ReorgT_Free\n");
		    // We won't free the base because it a global.
		    /*
		  for each element of base {
		    tree fndecl = builtin_decl_explicit( BUILT_IN_FREE);
		    gcall *call = gimple_build_call( fndecl, 1, element);
		    insert call before stmt
		  }
		  delete stmt
		    */
		    break;
		  case ReorgT_UserFunc:
		    {
		      DEBUG_L("ReorgT_UserFunc: ");
		      DEBUG_F( print_gimple_stmt, stderr, stmt, 0);
		      // Needed for helloworld.
		      // The type must be adjusted, but not here.

		      // Note, what is done is there is a case (for
		      // GIMPLE_CALL) in the mini-pass to adjust a
		      // call's "dangling" SSA temp.  I mean dangling
		      // in the sense that there are pointers to a
		      // reorg type on the left hand side of
		      // statements and they haven't been modified to
		      // use the correct reorg pointer
		      // represenatation, even though the right hand
		      // side has been.
		    }
		    break;
		  case ReorgT_Convert:
		    // Ignore type casting because another
		    // mini-pass sweeps up any ugly dangling types.
		    // TBD test this
		    DEBUG_L("ReorgT_Convert\n");
		    break;
		  case ReorgT_Return:
		    // TBD This case probably is unnecessary.
		    DEBUG_L("ReorgT_Return\n");
		    break;
		  default:
		    internal_error( "Invalid transformation");
		  }
	      }
	  }
	// Iterate over the PHIs and for any PHI that is a reorgtype,
	// transform any constant zero into it's new repersentation.
	// OR MAYBE... use FOR_EACH_PHI_ARG for the iterator...
	
	DEBUG_L("Phis with constant operands:\n");
	INDENT(4);
	gphi_iterator pi;
	for ( pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi))
	  {
	    //gimple_stmt_iterator gsi = as_a <gimple_stmt_iterator> pi;
	    gphi *phi = pi.phi ();
	    gimple *stmt = static_cast <gimple *> (phi);
	    
	    DEBUG_A("phi: ");
	    DEBUG_F( print_gimple_stmt, stderr, stmt, 0);

	    ReorgType_t *ri = contains_a_reorgtype( stmt, info);
	    if ( ri != NULL && number_of_levels ( TREE_TYPE ( PHI_RESULT ( stmt))) == 1 )
	      {
		for (int i = 0; i < gimple_phi_num_args (phi); i++)
		  {
		    tree *arg = gimple_phi_arg_def_ptr (phi, i);
		    DEBUG_A("arg[%d] = ",i);
		    DEBUG_F(flexible_print, stderr, *arg, 1, (dump_flags_t)0);
		    bool int_cst = TREE_CODE ( *arg) == INTEGER_CST;
		    DEBUG_A("is %sinteger constant\n", int_cst ? "" : "not ");
		    if ( int_cst && integer_zerop ( *arg) )
		      {
			*arg = TYPE_MAX_VALUE ( ri->pointer_rep);
			DEBUG_L("arg after = ");
			DEBUG_F(flexible_print, stderr, *arg, 1, (dump_flags_t)0);
		      }
		  }
	      }
	  }
	INDENT(-4);
      }
    pop_cfun ();
  }

  DEBUG_L("after bulk of transformations\n");

  DEBUG_F( print_program, info->reorg_dump_file, PRINT_FORMAT, 4, info);
  
  DEBUG ("INTERNALS PRINT\n");
  DEBUG_F (apply_to_all_gimple, print_internals, true, (void *)info);

  // A mini-pass to fixup dangling SSA temps.
  
  FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)
    {
      struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
      push_cfun ( func);

      std::vector <tree> ssa_to_delete;

      DEBUG_L("Mini-Pass on Function %s:\n", lang_hooks.decl_printable_name ( func->decl, 2));
      
      //DEBUG_L("\n");
      //DEBUG_F( wolf_fence, info);

      // We need a map of old ssa_name to new ssa_name. Not currently used.
      std::map <tree,tree> ssa_map;

      // Walk function decl.
      // Modify declaractions modifies the formal parameter types.
      // TBD That needs to be moved here
      // Never the less we need to associate new default defs with them.
      // At the end of find_decls_and_types adds parameter decls.
      // We'll use get_or_create_ssa_default_def on the ssa name and
      // create a new decl for the decls that are pointers to
      // reorg types.
      //
      // Then walk the gimple looking for dangling types. When we find
      // one on the right hand side check to see if it's on the
      // map. If not we create a ssa name and add it to the map.  We
      // subsitute it into operand.  For the left hand side we also
      // set the statement definition.

      // Default defs case first
      
      // For parameters

      // Note, we don't do anything unless it's necessary and it's
      // not necessay if it's been done before. Hence the possibility
      // of many functions mapping onto one declaration (which I
      // even doubt is possible in thi case) can't be a problem.
      
      DEBUG_L("Dangling Types for Function Params (default defs).\n");
      INDENT(4);
      tree parm;
      for ( parm = DECL_ARGUMENTS ( func->decl);
	    parm;
	    parm = DECL_CHAIN ( parm) )
	{
	  DEBUG_A("param: ");
	  DEBUG_F( print_generic_decl, stderr, parm, (dump_flags_t)0);
	  DEBUG("\n");
	  INDENT(2);
	  tree old_default_def = ssa_default_def ( func, parm);
	  DEBUG_A("old_default_def: ");
	  DEBUG_F( print_generic_expr, stderr, old_default_def, (dump_flags_t)0);
	  DEBUG("\n");
	  tree new_default_def;

	  // Modify prameter and do the default def stuff
	  
	  // Need to create a new decl rather than modify the existing
	  // one.
	  
	  if ( modify_decl_core ( &parm, info) )
	    {
	      DEBUG_A("double check new param: ");
	      DEBUG_F( print_generic_decl, stderr, parm, (dump_flags_t)0);
	      DEBUG("\n");
	      
	      // New default def here

	      // If the variable of the decl is initialized
	      // then it shouldn't be associated with a default def.
	      if ( old_default_def )
		{
		  // We must delete the old one or tranversing ssa names of
		  // the function will stumple across an SSA name associated
		  // with nothing, causing grief.
		  //
		  // We do it at the bottom of this code using a
		  // something I had to write (there was no existing
		  // mechanism.)

		  // Create new default def here.
		  // NOTE parm looks correct here but type of new_default_def
		  // is that of old_default_def so this might just look up
		  // old_default_def!
		  //new_default_def = get_or_create_ssa_default_def ( func, parm);
		  // ??? try this (in conjunction with the above) to fix things... NOPE
		  //set_ssa_default_def ( func, parm, new_default_def);
		  // ??? these instead
		  new_default_def = make_ssa_name_fn ( func, parm, gimple_build_nop ());
		  set_ssa_default_def ( func, parm, new_default_def);

		  DEBUG_A("new_default_def: ");
		  DEBUG_F(print_generic_expr, stderr, new_default_def, (dump_flags_t)0);
		  DEBUG(", TYPE: ");
		  DEBUG_F(print_generic_expr, stderr, TREE_TYPE(new_default_def), (dump_flags_t)0);
		  DEBUG("\n");

		  // TBD REMOVE DUPLICATE!
		  // Replace old one (not really totally hence the
		  // remove_default_def below.)
		  set_ssa_default_def ( func, parm, new_default_def);

		  imm_use_iterator iter;
		  gimple *stmt;
		  use_operand_p use;
		  // Modify stmts using old default def to use
		  // new default def
		  FOR_EACH_IMM_USE_STMT ( stmt, iter, old_default_def)  // <== use other form??? Not
		    {
		      DEBUG_A("before: ");
		      DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
		      use_operand_p use_p;
		      ssa_op_iter ssa_iter;
		      // The F_E_S_U_O macro was blowing up on a phi
		      //FOR_EACH_SSA_USE_OPERAND( use_p, stmt, ssa_iter, SSA_OP_USE )
		      FOR_EACH_PHI_OR_STMT_USE ( use_p, stmt, ssa_iter, SSA_OP_USE )
			{
			  if ( use_p == NULL ) continue;
			  tree use = USE_FROM_PTR (use_p);
			  DEBUG_A("use to replace: ");
			  DEBUG_F( print_generic_expr, stderr, use, (dump_flags_t)0);
			  DEBUG("\n");
			  if (use == old_default_def)
			    SET_USE ( use_p, new_default_def);
			}
		      DEBUG_A("after: ");
		      DEBUG_F ( print_gimple_stmt, stderr, stmt, 0);
		    }
		  // Get rid of the old default def because it confuses
		  //
		  //remove_default_def ( old_default_def, func);
		  ssa_to_delete.push_back ( old_default_def);
		  release_ssa_name_fn ( func, old_default_def);
		}
	    }
	  INDENT(-2);
	}
      INDENT(-4);
      
      DEBUG_L("Dangling Types for Function Local (default defs).\n");
      INDENT(4);
      //DEBUG_L("\n");
      //DEBUG_F( wolf_fence, info);
      
      // For locals
      //
      // Note, the code below looks half baked and might simply not
      // encountered anything that breaks it (see the code for the
      // parameters above how it might need to look.)
      //
      
      unsigned i;
      tree decl;
      FOR_EACH_LOCAL_DECL ( func, i, decl)
	{
	  DEBUG_A("local: ");
	  DEBUG_F( print_generic_decl, stderr, decl, (dump_flags_t)0);
	  DEBUG("\n");
	  tree old_default_def = ssa_default_def ( func, decl);
	  tree new_default_def;
	  
	  // Modify prameter and do the default def stuff
	  
	  // Again we'll need to create a new decl rather than modify
	  // the existing one.
	  
	  if ( modify_decl_core ( &decl, info) )
	    {
	      // New default def here

	      // If the variable of the decl is initialized
	      // then it shouldn't be associated with a default def.
	      if ( old_default_def )
		{
		  // TBD Do we delete the old one and if so,
		  // do we do it here and how do we do it?

		  // Create new default def here.
		  new_default_def = get_or_create_ssa_default_def ( func, decl);

		  imm_use_iterator iter;
		  gimple *stmt;
		  use_operand_p use;
		  // Modify stmts using old default def to use
		  // new default def
		  FOR_EACH_IMM_USE_STMT ( stmt, iter, old_default_def)
		    {
		      FOR_EACH_IMM_USE_ON_STMT ( use, iter)
			{
			  SET_USE ( use, new_default_def);
			}
		      // Possibly do this???
		      //update_stmt ( stmt);
		    }
		}
	    }
	}
      INDENT(-4);      
      
      // Normal ssa name case
      DEBUG_L("Dangling Types for Normal SSA Names:\n");
      //DEBUG_L("\n");
      //DEBUG_F( wolf_fence, info);
      
      INDENT(4);
      // We use len instead of using func->length() in the for loop test
      // because new ssa names are created in the loop body and we
      // shouldn't process them.
      unsigned int len = SSANAMES ( func)->length ();
      DEBUG_L("len = %d\n",len);
      for ( unsigned int i = 0; i < len; i++)
	{
	  DEBUG_L("SSANAMES(func)[%d]\n",i);

	  tree ssa_name = (*SSANAMES ( func))[i];

	  if( ssa_name == NULL )
	    {
	      DEBUG_L("Skip, ssa_name == NULL\n");
	      continue;
	    }

	  bool a_default_def = SSA_NAME_IS_DEFAULT_DEF ( ssa_name);
	  gimple *defining_stmt = SSA_NAME_DEF_STMT ( ssa_name);;
	  bool no_defining_stmt = defining_stmt == NULL;
	  bool defined_by_nop = defining_stmt && gimple_code ( defining_stmt) == GIMPLE_NOP;
	  tree type = TREE_TYPE ( ssa_name);
	  tree bottom_type = base_type_of ( type);
	  ReorgType_t *ri = get_reorgtype_info ( bottom_type, info);
	  DEBUG_L("ssa_name = ");
	  DEBUG_F(print_generic_expr, stderr, ssa_name, (dump_flags_t)0);
	  DEBUG(" %s", a_default_def ? "is default_def" : "");
	  DEBUG(" %s", no_defining_stmt ? "has no defining stmt" : "");
	  DEBUG(" %s", defined_by_nop ? "defined by a nop" : "");
	  DEBUG(", type = ");
	  DEBUG_F(print_generic_expr, stderr, type, (dump_flags_t)0);
	  DEBUG(", bottom_type = ");
	  DEBUG_F(print_generic_expr, stderr, bottom_type, (dump_flags_t)0);
	  DEBUG(", ri = %p\n",ri);

	  // If it's not a dangling type we don't care
	  if ( ri == NULL )
	    {
	      DEBUG_L("Skip, ri == NULL\n");
	      continue;
	    }

	  // A default def is processed seperately
	  if ( a_default_def )
	    {
	      DEBUG_L("Skip default_def\n");
	      continue;
	    }

	  gcc_assert ( !no_defining_stmt);
	  gcc_assert ( !defined_by_nop);

	  DEBUG_L("Defining stmt: ");
	  DEBUG_F ( print_gimple_stmt, stderr, defining_stmt, 0);

	  tree new_type = ri->pointer_rep;
	  tree new_ssa_name = make_temp_ssa_name( new_type, NULL, "dedangled");
	  DEBUG_L("new_ssa_name = ");
	  DEBUG_F(print_generic_expr, stderr, new_ssa_name, (dump_flags_t)0);
	  DEBUG("\n");
	  #if DEBUGGING
	  for ( unsigned int j = 0; j < SSANAMES ( func)->length (); j++)
	    {
	      if ( (*SSANAMES ( func))[j] == new_ssa_name )
		{
		  DEBUG_L("new name at j = %d\n",j);
		  break;
		}
	    }
	  #endif
	  
	  gimple *use_stmt;
	  imm_use_iterator iter;
	  FOR_EACH_IMM_USE_STMT ( use_stmt, iter, ssa_name)
	    {
	      DEBUG_L("use_stmt before: ");
	      DEBUG_F ( print_gimple_stmt, stderr, use_stmt, 0);
	      
	      // Deal with the uses
	      use_operand_p use_p;
	      ssa_op_iter ssa_iter;
	      // The F_E_S_U_O macro was blowing up on a phi
	      //FOR_EACH_SSA_USE_OPERAND( use_p, use_stmt, ssa_iter, SSA_OP_USE )
	      FOR_EACH_PHI_OR_STMT_USE ( use_p, use_stmt, ssa_iter, SSA_OP_USE )
		{
		  DEBUG_L("use_p = %p\n",use_p);
		  if ( use_p == NULL ) continue;
		  tree use = USE_FROM_PTR (use_p);
		  if (use == ssa_name)
		    SET_USE ( use_p, new_ssa_name);
		}
	      DEBUG_L("use_stmt after: ");
	      DEBUG_F ( print_gimple_stmt, stderr, use_stmt, 0);
	      
	      // Should update_stmt be called here?
	      // It does not seem either harm or help so I'll
	      // leave it in.
	      update_stmt ( use_stmt);
	    }
	  // Modify the LHS too
	  // TBD This code needs to be more general.
	  DEBUG_L("What is ssa_name? ");
	  DEBUG_F(flexible_print, stderr, ssa_name, 1, (dump_flags_t)0);
	  gimple *def = SSA_NAME_DEF_STMT ( ssa_name);
	  
	  DEBUG_L("def: ");
	  DEBUG_F ( print_gimple_stmt, stderr, def, 0);
	  
	  set_lhs_for ( def, new_ssa_name);

	  update_stmt ( def);

	  // This is where we know that ssa_name needs to be replaced
	  release_ssa_name_fn ( func, ssa_name);
	  
	}
      INDENT(-4);

      // Might be a bad idea.
      #if 0
      for ( auto iter = ssa_to_delete.begin ();iter != ssa_to_delete.end (); iter++ )
	{
	  remove_default_def ( *iter, func);
	}
      #endif

      pop_cfun ();
    }

  DEBUG_L("after mini-passes\n");

  if ( info->show_all_reorg_cands )
    {
      fprintf ( info->reorg_dump_file, "End of str_reorg_instance_interleave_trans:\n");
      print_program ( info->reorg_dump_file, PRINT_FORMAT, 4, info);
    }

  // TBD Should this be a diagnostic or not?
  DEBUG ("INTERNALS PRINT\n");
  DEBUG_F (apply_to_all_gimple, print_internals, true, (void *)info);
  
  // Spin through all the functions and recompute the dominace info.
  FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)  {
    struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
    push_cfun ( func);
    if ( dom_info_available_p ( CDI_DOMINATORS) )
      {
	free_dominance_info ( CDI_DOMINATORS);
      }
    calculate_dominance_info (CDI_DOMINATORS);
    pop_cfun ();
  }
  return 0;
}

// Note, the following code might be a bit overly simplistic.
static void
set_lhs_for ( gimple *stmt, tree ssa_name)
{
  switch ( gimple_code ( stmt))
    {
    case GIMPLE_ASSIGN:
      gimple_assign_set_lhs ( stmt, ssa_name);
      break;
    case GIMPLE_CALL:
      gimple_call_set_lhs ( stmt, ssa_name);
      break;
    case GIMPLE_PHI:
		  {
		    gphi *phi_stmt = as_a <gphi *> ( stmt);
		    gimple_phi_set_result ( phi_stmt, ssa_name);
		  }
		  break;
    default:
      fprintf ( stderr, "error: unprecidented gimple for set_lhs_for\n    ");
      print_gimple_stmt( stderr, stmt, 0);
      gcc_assert ( 0);
    }
}

// TBD no longer used... preserve it for a bit, then remove it.
static void
wrangle_ssa_type( tree side, Info_t *info )
{
  tree side_type = TREE_TYPE ( side);
  tree bottom_type = base_type_of ( side_type);
  //DEBUG_L("op: ");
  //DEBUG_F(print_generic_expr, stderr, side, (dump_flags_t)0);
  //DEBUG("\n");
  //DEBUG_L("bottom_type: ");
  //DEBUG_F(print_generic_expr, stderr, bottom_type, (dump_flags_t)0);
  //DEBUG("\n");

  // Maybe we sould pass in ri as an argument???
  ReorgType_t *ri = get_reorgtype_info ( bottom_type, info);
  tree prev_type = side_type;
  tree type = TREE_TYPE ( prev_type);
  //DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type);
  int levels;
  for ( levels = 0; TREE_CODE ( type) == POINTER_TYPE; levels++ )
    {
      prev_type = type;
      type = TREE_TYPE ( prev_type);
      //DEBUG_L( "prev_type: %p, type: %p\n", prev_type, type);
    }

  // I thought about doing this:
  //   Modify type of ssa temp (dicey!)
  //   This changes every instance of * reorg_type to the
  //   new pointre rep in one fell swoop.
  //   I sweat just thinking how crazy this is....
  //
  //   TREE_TYPE ( prev_type) = ri->pointer_rep;

  // TBD might use build_pointer_type to build new type for *(N)reorg_type
  // to *(N-1)ri->pointer_rep
  // Fakes this for levels == 1
  if ( levels == 0)
    {
      //DEBUG_L( "LEVELS  ZERO\n");
      modify_ssa_name_type ( side, ri->pointer_rep);
      //DEBUG_L("after modify_ssa_name_type\n");
    }
  else
    {
      //DEBUG_L( "LEVELS > ZERO\n");
      gcc_assert(0);
    }
}

void
print_internal_op ( tree op)
{
  tree type = TREE_TYPE ( op);
  print_generic_expr ( stderr, op, (dump_flags_t)0);
  fprintf( stderr, "  TYPE:  ");
  print_generic_expr ( stderr, type, (dump_flags_t)0);
  fprintf( stderr, "  MAIN_TYPE:  ");
  print_generic_expr ( stderr, TYPE_MAIN_VARIANT ( type), (dump_flags_t)0);
  fprintf( stderr, "\n");
}

bool
print_internals (gimple *stmt, void *data)
{
  Info_t *info = (Info_t*)data;

  print_gimple_stmt ( stderr, stmt, TDF_SLIM);

  if ( gimple_code ( stmt) == GIMPLE_ASSIGN )
    {
      tree lhs = gimple_assign_lhs( stmt);
      tree rhs1 = gimple_assign_rhs1( stmt);
      tree rhs2 = gimple_assign_rhs2( stmt);
      tree rhs3 = gimple_assign_rhs3( stmt);
      gcc_assert ( lhs);
      gcc_assert ( rhs1);
      
      bool lhs_reorg = tree_contains_a_reorgtype_p ( lhs, info);
      //DEBUG_L("rhs1 = ");
      //DEBUG_F(flexible_print, stderr, rhs1, 1, (dump_flags_t)0);
      bool rhs1_reorg = tree_contains_a_reorgtype_p ( rhs1, info);
      bool rhs2_reorg = tree_contains_a_reorgtype_p ( rhs2, info);
      bool rhs3_reorg = tree_contains_a_reorgtype_p ( rhs3, info);
      
      bool lhs_ssa = lhs_reorg && TREE_CODE(lhs) == SSA_NAME;
      bool rhs1_ssa = rhs1_reorg && TREE_CODE(rhs1) == SSA_NAME;
      bool rhs2_ssa = rhs2_reorg && TREE_CODE(rhs2) == SSA_NAME;
      bool rhs3_ssa = rhs3_reorg && TREE_CODE(rhs3) == SSA_NAME;

      fprintf( stderr, "  LHS%s: ", lhs_ssa ? "*" : "");
      print_generic_expr ( stderr, TREE_TYPE ( lhs), (dump_flags_t)0);

      fprintf( stderr, ",  RHS1%s: ", rhs1_ssa ? "*" : "");
      print_generic_expr ( stderr, TREE_TYPE ( rhs1), (dump_flags_t)0);

      if ( rhs2 )
	{
	  fprintf( stderr, ",  RHS2%s: ", rhs2_ssa ? "*" : "");
	  print_internal_op ( rhs2);
	}

      if ( rhs3 )
	{
	  fprintf( stderr, ",  RHS3%s: ", rhs3_ssa ? "*" : "");
	  print_internal_op ( rhs3);
	}
      fprintf ( stderr, "\n");
    } else
    if ( gimple_code ( stmt) == GIMPLE_PHI )
      {
	use_operand_p phi_op;
	ssa_op_iter iter;
	gphi *phi_stmt = dyn_cast <gphi *> ( stmt);

	tree def = PHI_RESULT ( phi_stmt);
	fprintf( stderr, "  OP: ");
	print_internal_op ( def);
	
	FOR_EACH_PHI_ARG ( phi_op, phi_stmt, iter, SSA_OP_ALL_OPERANDS)
	  {
	    tree op = USE_FROM_PTR ( phi_op);
	    fprintf( stderr, "  OP: ");
	    print_internal_op ( op);
	  }
      }
    else
      {
	ssa_op_iter iter;
	tree op_def;
	use_operand_p opu;
	FOR_EACH_SSA_TREE_OPERAND ( op_def, stmt, iter, SSA_OP_ALL_DEFS)
	  {
	    fprintf( stderr, "  DEF OP: ");
	    print_internal_op ( op_def);
	  }
	FOR_EACH_SSA_USE_OPERAND ( opu, stmt, iter, SSA_OP_ALL_USES)
	  {
	    tree use_op = USE_FROM_PTR ( opu);
	    fprintf( stderr, "  USE OP: ");
	    print_internal_op ( use_op);
	  }
      }
  
  return false;
}

static void
str_reorg_instance_interleave_qual_part ( Info *info)
{
  // TBD save the return value so we can bypass further
  // instance interleaving if none of it is profitable.
  reorg_perf_qual ( info);
}

static void
str_reorg_instance_interleave_type_part ( Info *info)
{
  create_new_types ( info);
}

// Typse for performance qualification

typedef struct reorg_bb_info reorg_bb_info_t;
struct reorg_bb_info {
  basic_block *bb;
};

typedef struct perf_bb_info perf_bb_info_t;

struct acc_base_info {
  bool a_def_def;
  bool a_decl;
  bool a_func;
  bool has_induct_var_acc;
  bool multi_induct;
  bool complicated;
  // TBD Note could look at sign of operation for the
  // induction. Variables moving forward are different (cache access
  // wise) that those moving backward do the sort/compress shouldn't
  // lump them together.
  tree acc_base;
  tree induct_base;
  gimple *function;
};

struct varInfo {
  // Varpool_nodes are a pain to get at so I'll just
  // use the first entry in a run of access info enties
  // where all of the information but the field is the
  // same.
  //varpool_node *var;
  acc_info_t *rep_access;
  // This seems bit map scheme seems tedious and unnecessay.
  // just use the fields
  // sbitmap *bits;
  std::list<tree> fields;
  // The count doesn't vary in the simplified scheme
  //double  count;
};

struct acc_info {
  // trying to get to the varpool seems too hard
  // so I'll try for he decl
  //varpool_node *v;
  tree access;
  tree field; // int field_num;
  acc_base_info_t base_info;
  ReorgType_t *reorg;
};

//struct perf_loop_info {
//  std::vector <varInfo_t*> *vari;
//  class loop *gcc_loop;
//};

static void account_for_access( tree, tree, std::vector <acc_info_t> *, Info_t *);
static bool is_array_access( tree);

static unsigned int
reorg_perf_qual ( Info *info)
{
  if ( info->show_perf_qualify )
    {
      fprintf ( info->reorg_dump_file, "Doing Performance Qualification\n");
    }
  DEBUG_L("reorg_perf_qual:\n");
  #if 1
  // TBD use design in doc but mark ReorgTypes
  // (do_instance_interleave) that qualify instead of deleting them
  // unless both dead field elimination and field reorderig are not
  // viable (use do_dead_field_elim and do_field_reorder in
  // Reorg_type_t.)
  
  // For the mean time assume if a ReorgType made it here then it's qualified.
  for ( int i = 0; i < info->reorg_type->size (); i++ )
    {
      (*(info->reorg_type))[i].do_instance_interleave = true;
    }
  #endif
  #if 1
  // We are doing a quick and dirty version of performance
  // qualification for testing purposes and possibly the
  // initial version of for the main branch.
  auto reorg_types = info->reorg_type;

  // These are floating point numbers because of the fractional
  // accesses associated the probabilistic approach taken
  // below. By taken below I refer to full algorithm and the
  // quick and dirty initial version.
  
  // reorg was not possible for these
  double cache_accesses = 0.0;

  // reorg possible for these. This doesn't mean it is
  // profitable or even legal for all the types lumped
  // in together here. However, the sum of this and
  // cache_accesses should account for all the array
  // accesses in the program.
  double cache_accesses_noreorg = 0.0;

  // Perf Analysis
  struct cgraph_node *node;
  
  FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)  {
    struct function *func = DECL_STRUCT_FUNCTION ( node->decl);

    if ( info->show_perf_qualify )
      {
	fprintf ( info->reorg_dump_file, "Function: ");
	print_generic_expr ( info->reorg_dump_file,
			     TREE_TYPE(TREE_TYPE( func->decl)),
			     (dump_flags_t)0);
      }
    
    // Ulgy GCC idiom with global pointer to current function.
    // However, the dominace calculations other things need it.
    push_cfun ( func);

    if ( dom_info_available_p ( CDI_DOMINATORS) )
      {
	free_dominance_info ( CDI_DOMINATORS);
      }
    calculate_dominance_info (CDI_DOMINATORS);

    if ( info->show_perf_qualify )
      {
	fprintf ( info->reorg_dump_file,"  Function: %s\n",
		  lang_hooks.decl_printable_name ( func->decl, 2));
      }

    
    // TBD
    //std::vector<perf_loop_info> loop_perf;
    //loop_perf.reserve ( number_of_loops ( func));
    class loop *loop;
    bool missing_cases = false;
    FOR_EACH_LOOP_FN ( func, loop, LI_ONLY_INNERMOST )
      {
	//We don't need these
	//loop_perf [ loop->num ].vari = new std::vector<varInfo_t*>; // ???
	//loop_perf [ loop->num ].gcc_loop = loop;

	std::vector<acc_info_t> acc_info;
	std::vector<varInfo_t> var_info;
	
        size_t num_bbs = loop->num_nodes;
	basic_block *bbs = get_loop_body ( loop);

	// For the basic blocks in the the loop
	for ( unsigned i = 0; i < loop->num_nodes; i++)
	  {
	    basic_block bb = bbs [i];
	    //DEBUG_A("BB %i:\n", bb->index);
	    INDENT(4);
	    for ( auto gsi = gsi_start_bb ( bb); !gsi_end_p ( gsi); gsi_next ( &gsi) )
	      {
		gimple *stmt = gsi_stmt ( gsi);
		//DEBUG_A("examine: ");
		//DEBUG_F ( print_gimple_stmt, stderr, stmt, TDF_DETAILS);
		INDENT(4);
		unsigned n_ops = gimple_num_ops( stmt);
		tree op;
		unsigned ith_op;
		for ( ith_op = 0; ith_op < n_ops; ith_op++ )
		  {
		    op = gimple_op ( stmt, ith_op);
		    // It's lieing about the number of operands... so...
		    if ( op == NULL ) continue;
		    //DEBUG_A("op[%d]: %p", ith_op, op);
		    //DEBUG_F(flexible_print, stderr, op, 0, (dump_flags_t)0);
		    ReorgType_t *tri = tree_contains_a_reorgtype ( op, info);
		    enum ReorgOpTrans optran = recognize_op ( op, false, info);
		    // TBD This is where we need to remember
		    // each germane access
		    const char *s = optrans_to_str( optran);
		    // Commenting out these 3 debug commands causes a
		    // regression
		    //DEBUG_A(", %s\n", s);
		    if ( tri != NULL )
		      {
			//DEBUG(", ");
			//DEBUG_F(print_reorg, stderr, 0, tri);
		      }
		    else
		      {
			//DEBUG("\n");
			;
		      }
		    switch ( optran)
		      {
		      case ReorgOpT_Indirect:
			{
			  // TBD
			  // Is the var an induction variable for this loop?
			  // If so find the assocaite varpool_node and push
			  // it and the field onto var_acc_info;
			  tree op_var = TREE_OPERAND( op, 0);
			  tree op_field = TREE_OPERAND( op, 1);
			  // Since doesn't have an easily exposed mechanism
			  // for induction variable I'm hand waving here.
			  if ( !expr_invariant_in_loop_p ( loop, op_var) )
			    {
			      account_for_access ( op_var, op_field, &acc_info, info);
			    }
			}
			break;
		      case ReorgOpT_Array:
			{
			  // TBD
			  // Is the var an induction variable for this loop?
			  // If so find the assocaite varpool_node and push
			  // it and the field onto var_acc_info;
			  tree op_var = TREE_OPERAND( op, 0);
			  tree op_field = TREE_OPERAND( op, 1);
			  // Since doesn't have an easily exposed mechanism
			  // for induction variable I'm hand waving here.
			  if ( !expr_invariant_in_loop_p ( loop, op_var) )
			    {
			      account_for_access ( op_var, op_field, &acc_info, info);
			    }
			}
		      case ReorgOpT_AryDir:
		      case ReorgOpT_Deref: // ??
			missing_cases = true;
		      }
		  }
		INDENT(-4);
	      }
	    INDENT(-4);
	  }

	//DEBUG_L("Dumping acc_info:\n");
	for ( auto aci = acc_info.begin (); aci != acc_info.end (); aci++ )
	  {
	    //DEBUG_A("variable:\n");
	    //DEBUG_F( tell_me_about_ssa_name, (*aci).access, debug_indenting + 4);
	    //DEBUG_A("field: ");
	    //DEBUG_F( flexible_print, stderr, (*aci).field, 1, (dump_flags_t)0);
	  }

	//DEBUG_A("before sort: \n");
	//DEBUG_F(print_acc_infos, stderr, acc_info );

	// Sort and compact the access infos.
	stable_sort ( acc_info.begin (), acc_info.end (), acc_lt);

	//DEBUG_A("before compress: \n");
	//DEBUG_F(print_acc_infos, stderr, acc_info );

	// Sort and compact the access infos.
	std::stable_sort ( acc_info.begin (), acc_info.end (), acc_lt);
	
	compress_acc_infos ( acc_info );

	DEBUG_A("after compress: \n");
	DEBUG_F(print_acc_infos, stderr, acc_info );
	
	// Obtain loop count by looking at all the block counts.
	unsigned loop_count = 0;
	for ( unsigned i = 0; i < loop->num_nodes; i++)
	  {
	    basic_block bb = bbs [i];
	    loop_count = MAX( loop_count, bb->count.value ());
	  }
	DEBUG_L("loop_count = %d, nb_iterations_estimate = %ld\n",
		loop_count, loop->nb_iterations_estimate);

	// Create the variable infos
	varInfo_t var_entry;
	var_entry.rep_access = &acc_info[0];
	unsigned len = acc_info.size ();
 	if ( len == 1 )
	  {
	    var_entry.fields.push_front ( acc_info[0].field);
	  }
	else
	  {
	    unsigned i, j;
	    for ( i = 0, j = 1; j < len; j++ )
	      {
		acc_info_t *a_of_i = &acc_info[i];
		acc_info_t *a_of_j = &acc_info[j];
		var_entry.fields.push_front ( a_of_i->field);
		if ( !all_but_field_eq ( *a_of_i, *a_of_j ) )
		  {
		    var_info.push_back( var_entry);
		    var_entry.rep_access = a_of_j;
		    var_entry.fields.clear ();
		    a_of_i = a_of_j;
		  }
	      }
	  }
	var_info.push_back( var_entry);

	print_var_infos ( stderr, var_info);

	//
	// Model the performance
	//
	DEBUG_A("Model The Performance\n");

	// Originally this was done per bb but now it has to be per
	// loop. TBD But perf_bb is per loop so we need something similar
	// per loop.

	for ( auto pvi = var_info.begin (); pvi != var_info.end (); pvi++ )
	  { // 676
	    //tree base_type = base_type_of( pvi->rep_access.access);
	    ReorgType_t *ri = pvi->rep_access->reorg;
	    
	    // Reorg accounting
	    DEBUG_L("\n");
	    DEBUG_A("Reorg Accounting\n");
	    
	    if( ri != NULL )
	      {
		double reorg_nca = 0.0;

		DEBUG_A("  for: ");
		DEBUG_F( flexible_print, stderr, ri->gcc_type, 1, (dump_flags_t)0);

		INDENT(4);
		for ( auto fldi = pvi->fields.begin (); fldi != pvi->fields.end (); fldi++ )
		  {
		    unsigned HOST_WIDE_INT fld_width =
		      tree_to_uhwi ( DECL_SIZE ( *fldi));
		    double effect = alignment_effect ( fld_width);
		    double product = loop_count * effect;
		    reorg_nca += product;
		    DEBUG_A("Add loop_count * effect (%d * %f = %f) to reorg_nca (now %f)\n",
			    loop_count, effect, product, reorg_nca);
		  }
		INDENT(-4);
		ri->instance_interleave.reorg_perf += reorg_nca;
		DEBUG_A("Add reorg_nca (%f) to reorg_perf (now %e)\n",
			reorg_nca, ri->instance_interleave.reorg_perf);
              } // 699

	    // regular accounting
	    DEBUG_L("\n");
	    DEBUG_A("Regular Accounting\n");
	    
	    double regular_nca = 0.0;
	    sbitmap cache_model = sbitmap_alloc(1);
	    
	    for( auto pv2i = var_info.begin (); pv2i != var_info.end (); pv2i++ )
	      { // 704
		tree access = pv2i->rep_access->base_info.acc_base;
		tree base_type; // = base_type_of ( access);
		if ( pv2i->rep_access->reorg != NULL )		  {
		    base_type = pv2i->rep_access->reorg->gcc_type;
		  }
		else
		  {
		    if ( TREE_TYPE ( access ) != NULL )
		      {
			base_type = base_type_of ( access);
		      }
		    else
		      {
			gcc_assert (0);
		      }
		  }

		bool base_type_isa_decl = DECL_P ( base_type );

		// create a tiny model of the cache big
		// enough for this record.
		tree base_type_size = base_type_isa_decl ?
		  DECL_SIZE ( base_type )
		  :
		  TYPE_SIZE ( base_type);
		    
		unsigned HOST_WIDE_INT len =
		  (( tree_to_uhwi ( base_type_size)
		     +
		     param_l1_cache_line_size -1)
		   /
		   param_l1_cache_line_size)
		  +
		  1;
		DEBUG_L("\n");
		DEBUG_A("cache len = %d\n", len);
	      
		// TBD Does this clear the bits??? It needs to.
		// Each bit represents a cache line.
		cache_model = sbitmap_resize( cache_model, (unsigned) len, 0);
		double accum = 0.0;
		int nrbo = 0;
		if ( base_type_isa_decl )
		  {
		    for ( auto field_ex = TYPE_FIELDS ( base_type);
			  field_ex; 
			  field_ex = DECL_CHAIN ( field_ex) )
		      {
			nrbo++;
			// Looking back on my design I don't have a clue
			// why this is here and what it does. Sigh...
			unsigned HOST_WIDE_INT base_offset =
			  tree_to_uhwi ( DECL_FIELD_OFFSET( field_ex));
			DEBUG_L("\n");
			DEBUG_A("For field_ex: ");
			DEBUG_F( flexible_print, stderr, field_ex, 0, (dump_flags_t)0);
			DEBUG(", nrbo %d, base_offset %d\n", nrbo, base_offset);
			
			// Access accounting

			INDENT(4);
			for ( auto fldi = pv2i->fields.begin ();
			      fldi != pv2i->fields.end (); fldi++ )
			  {
			    tree field = *fldi;
			    unsigned HOST_WIDE_INT fld_width, fld_offset;
			    fld_width = tree_to_uhwi ( DECL_SIZE ( field));
			    fld_offset = tree_to_uhwi ( DECL_FIELD_OFFSET ( field));
			    DEBUG_A("Field: ");
			    DEBUG_F( flexible_print, stderr, field, 0, (dump_flags_t)0);
			    DEBUG(", width = %d, offset = %d\n", fld_width, fld_offset);
			    int chari;
			    INDENT(4);
			    for ( chari = 0; chari < fld_width; chari++ )
			      {
				int loc = (chari + fld_offset + base_offset)
				  /
				  param_l1_cache_line_size;
				DEBUG_A("loc: %d\n", loc);
				bitmap_set_bit ( cache_model, loc);
			      }
			    INDENT(-4);
			  }
			INDENT(-4);
			unsigned bcount = bitmap_count_bits ( cache_model);
			accum += bcount;
			DEBUG_L("\n");
			DEBUG_A("Add popcount of cache (%d) to accum (now %f)\n",
				bcount, accum);
			bitmap_clear ( cache_model);
		      }
		  }
		else
		  {
		    nrbo = 1;
		    accum++;
		    DEBUG_L("\n");
		    DEBUG_A("nrbo = 1, increment accum to %f\n", accum);
		  }
		#if 1	
		double amount = accum / nrbo;
		double product = amount * loop_count;
		regular_nca += product;
		DEBUG_L("\n");
		DEBUG_A("Add loop_count*accum/nrbo (%f*%f/%d = %f) to regular_nca (now %e)\n",
			loop_count, accum, nrbo, product, regular_nca);
		#else
		double amount = accum / nrbo;
		regular_nca += amount;
		DEBUG_L("\n");
		DEBUG_A("Add accum/nrbo (%f/%d = %f) to regular_nca (now %e)\n",
			accum, nrbo, amount, regular_nca);
		#endif
	      } // 739
	    sbitmap_free ( cache_model);
	    
	    if( ri != NULL ) {
	      ri->instance_interleave.regular_perf += regular_nca;
              cache_accesses_noreorg += regular_nca;
	      DEBUG_L("\n");
	      DEBUG_A("Add regular_nca (%f) to regular_perf (now %e)",
		      regular_nca, ri->instance_interleave.regular_perf);
	      DEBUG_A("  and to cache_accesses_noreorg (now %e)\n",
		      cache_accesses_noreorg);
            } else {
	        cache_accesses += regular_nca;
            }
	  } // end for prop_var
      } //

    if ( info->show_perf_qualify && missing_cases )
      {
	fprintf ( info->reorg_dump_file,
		  "    Ignored unimplemented cases when finding accesses.\n");
      }
    
    free_dominance_info ( CDI_DOMINATORS);
    pop_cfun ();
  }

  // TBD Somebody somewhere needs to compute:
  //   reorg_perf
  //   regular_perf
  //   cache_accesses
  //   cache_accesses_noreorg

  double total_cache_accesses =
    cache_accesses + cache_accesses_noreorg;

  info->total_cache_accesses = total_cache_accesses;

  if ( info->show_perf_qualify )
    {
      fprintf ( info->reorg_dump_file, "total_cache_accesses: %e\n\n",
		total_cache_accesses);
    }

  if ( info->show_perf_qualify )
    {
      fprintf ( info->reorg_dump_file,
		"Decide which reorgTypes fail performance qualification\n");
    }
  //
  // Decide which reorgTypes fail performance qualification
  //

  // We have the total accesses per type. Use that to see
  // if the type qualifies.
  for ( auto reorgi = reorg_types->begin ();
	reorgi != reorg_types->end (); reorgi++ )
    {
      double with_opt = reorgi->instance_interleave.reorg_perf;
      double without_opt = reorgi->instance_interleave.regular_perf;
      double raw_effect = with_opt/without_opt;
      double absolute_effect =
        (without_opt - with_opt) / total_cache_accesses;
      DEBUG_A("For ");
      DEBUG_F(flexible_print, stderr, reorgi->gcc_type, 0, (dump_flags_t)0);
      DEBUG(" with_opt: %e, without_opt %e, total_cache_accesses %e\n",
	    with_opt, without_opt, total_cache_accesses);
      DEBUG_A("  Raw Effect: %5.4f, Absolute Effect %5.4f\n",
	      raw_effect, absolute_effect);

      // Note, there would need to be a multi-pool case here if
      // that is every done.

      // If the relative effect is small enough don't bother.
      if ( raw_effect < SINGLE_POOL_RAW_SKIP_IT )
	{
	  if ( info->show_perf_qualify )
	    {
	      fprintf ( info->reorg_dump_file, "  Disqualified: ");
	      flexible_print ( info->reorg_dump_file, reorgi->gcc_type, 0,
			       (dump_flags_t)0);
	      fprintf ( info->reorg_dump_file, ": Very small effect:\n");
	      fprintf ( info->reorg_dump_file,
			"    raw_effect %5.4 < SINGLE_POOL_RAW_SKIP_IT %5.4\n",
			raw_effect, SINGLE_POOL_RAW_SKIP_IT);
	    }
	  reorgi->do_instance_interleave = false;
	  continue;
	}
      // the relative effect is big enough do it anyway
      // otherwise look at the absolute effect.
      if ( raw_effect >= SINGLE_POOL_RAW_DO_IT_ALWAYS )
	{

	  if ( info->show_perf_qualify )
	    {
	      fprintf ( info->reorg_dump_file, "  Qualified: ");
	      flexible_print ( info->reorg_dump_file, reorgi->gcc_type, 0,
			       (dump_flags_t)0);
	      fprintf ( info->reorg_dump_file, ": Large raw effect:\n");
	      fprintf ( info->reorg_dump_file,
			"    raw_effect %5.4f >= SINGLE_POOL_RAW_DO_IT_ALWAYS %5.4f\n",
			raw_effect, SINGLE_POOL_RAW_DO_IT_ALWAYS);
	    }
	  
	  reorgi->do_instance_interleave = true;
	  continue;
	}
      if ( absolute_effect < SINGLE_POOL_ABS_SKIP_IT )
	{
	  if ( info->show_perf_qualify )
	    {
	      fprintf ( info->reorg_dump_file, "  Disqualified: ");
	      flexible_print ( info->reorg_dump_file, reorgi->gcc_type, 0,
			       (dump_flags_t)0);
	      fprintf ( info->reorg_dump_file, ": Very small absolute effect:\n");
	      fprintf ( info->reorg_dump_file,
			"    absolute_effect %5.4f < SINGLE_POOL_ABS_SKIP_IT %5.4f\n",
			absolute_effect, SINGLE_POOL_ABS_SKIP_IT);
	    }
	  
	  reorgi->do_instance_interleave = false;
	  continue;
	}
      if ( absolute_effect >= SINGLE_POOL_ABS_DO_IT_ALWAYS )
	{

	  if ( info->show_perf_qualify )
	    {
	      fprintf ( info->reorg_dump_file, "  Qualified: ");
	      flexible_print ( info->reorg_dump_file, reorgi->gcc_type, 0,
			       (dump_flags_t)0);
	      fprintf ( info->reorg_dump_file, ": Large absolute effect:\n");
	      fprintf ( info->reorg_dump_file,
			"    absolute_effect %5.4f >= SINGLE_POOL_ABS_DO_IT_ALWAYS %5.4f\n",
			absolute_effect, SINGLE_POOL_ABS_DO_IT_ALWAYS);
	    }
	  
	  reorgi->do_instance_interleave = true;
	  continue;
	}
      
      // We fitted a linear equation to the corners of the
      // effects above and use it to determine when
      // to disqualify a type
      double cut_off = cut_off_eq_single_pool ( absolute_effect);
      if ( raw_effect < cut_off )
	{

	  if ( info->show_perf_qualify )
	    {
	      fprintf ( info->reorg_dump_file, "  Disqualified: ");
	      flexible_print ( info->reorg_dump_file, reorgi->gcc_type, 0,
			       (dump_flags_t)0);
	      fprintf ( info->reorg_dump_file, ": Failed cut off equations:\n");
	      fprintf ( info->reorg_dump_file,
			"    raw_effect %5.4f < cut_off %5.4f\n",
			raw_effect, cut_off);
	    }
	  
	  reorgi->do_instance_interleave = false;
	  continue;
	}

      if ( info->show_perf_qualify )
	{
	  fprintf ( info->reorg_dump_file, "  Qualified: ");
	  flexible_print ( info->reorg_dump_file, reorgi->gcc_type, 0,
			   (dump_flags_t)0);
	  fprintf ( info->reorg_dump_file, ": Passed cut off equations:\n");
	  fprintf ( info->reorg_dump_file,
			"    raw_effect %5.4f >= cut_off %5.4f\n",
			raw_effect, cut_off);
	}
      
    }
  #endif
}

static void
print_var_info ( FILE *file, varInfo_t &vinfo)
{
  print_acc_info ( file, vinfo.rep_access );
  for ( auto fi = vinfo.fields.begin (); fi != vinfo.fields.end (); fi++ )
    {
      if ( fi != vinfo.fields.begin () ) fprintf ( stderr,", ");
      flexible_print (  stderr, *fi, 0, (dump_flags_t)0);
    }
  fprintf ( stderr,"\n");
}

static void
print_var_infos ( FILE *file, std::vector<varInfo_t> &vinfo)
{
  fprintf( stderr, "print_var_infos:\n");
  for ( auto vi = vinfo.begin (); vi != vinfo.end (); vi++ )
    {
      print_var_info ( file, *vi);
    }
}

static void
compress_acc_infos ( std::vector <acc_info_t> ainfo )
{
  unsigned len = ainfo.size ();
  if ( len == 1 ) return;
  unsigned i, j;
  for ( i = j = 1; j < len; j++ )
    {
      ainfo[i] = ainfo[j];
      if ( !acc_eq ( ainfo[i], ainfo[i - 1]) ) i++;
    }
  if ( i == j ) return;
  ainfo.resize ( len - (j -i));
}

static void
print_acc_info ( FILE *file, acc_info_t *ainfo )
{
  fprintf ( file, "%s%s%s%s%s%s\n",
	    ainfo->base_info.a_def_def ? ", deflt_def" : "",
	    ainfo->base_info.a_decl ? ", decl" : "",
	    ainfo->base_info.a_func ? ", a_func" : "",
	    ainfo->base_info.has_induct_var_acc ? ", induct" : "",
	    ainfo->base_info.multi_induct ? ", multi" : "",
	    ainfo->base_info.complicated ? ", complicated" : "");
  fprintf ( file, "   base var ");
  flexible_print ( stderr, ainfo->base_info.acc_base, 0, (dump_flags_t)0);
  if ( ainfo->base_info.has_induct_var_acc )
    {
      fprintf ( file, ", induc var ");
      flexible_print ( stderr, ainfo->base_info.acc_base,
		       0, (dump_flags_t)0);
    }
  fprintf ( file, ", field ");
  flexible_print ( stderr, ainfo->field, 0, (dump_flags_t)0);
  if ( ainfo->reorg )
    {
      fprintf ( file, ", reorg of ");
      flexible_print ( stderr, ainfo->reorg->gcc_type,
		       0, (dump_flags_t)0);
    }
  fprintf ( file, "\n");
}

static void
print_acc_infos ( FILE *file, std::vector <acc_info_t> ainfo )
{
  fprintf ( file, "print_acc_infos:\n");
  unsigned i;
  unsigned len = ainfo.size ();

  for ( i = 0; i < len; i++ )
    {
      fprintf ( file, "[%d] ", i);
      print_acc_info ( file, &ainfo[i]);
    }
}


// decls < default defs < defined by function
static bool
acc_lt_acc_category ( const acc_info_t& a, const acc_info_t& b )
{
  int ord_a = a.base_info.a_decl ? 1 : a.base_info.a_def_def ? 2 : 3;
  int ord_b = b.base_info.a_decl ? 1 : b.base_info.a_def_def ? 2 : 3;
  if ( ord_a < ord_b ) return true;
  if ( ord_a > ord_b ) return false;
  switch ( ord_a ) {
  case 1:
    // The field isn't there for decls, it's the index. Ignoring the
    // index is harmless.  This is becauseif if we take an arbitary
    // small number of iterations of a loop, then all the permutations
    // of the accesses in those iterations touch the same number of
    // cache lines (just in a different order.)
    return false;
  case 2:
    {
      if ( a.access < b.access ) return true;
      if ( a.access > b.access ) return false;
      return a.field < b.field;
    }
  case 3:
    {
      if ( a.base_info.function < b.base_info.function ) return true;
      if ( a.base_info.function > b.base_info.function ) return false;
      return a.field < b.field;
    }
  }
}

// Complicated is less than noncomplicated and null reorgs are less than non
// null reorgs.
static bool
acc_lt ( const acc_info_t& a, const acc_info_t& b )
{
  if ( a.base_info.complicated && !b.base_info.complicated ) return true;
  if ( !a.base_info.complicated && !b.base_info.complicated ) return false;
  if ( a.reorg == NULL )
    {
      if ( b.reorg != NULL ) return true;
      // compare non_reorg_bit
      return acc_lt_acc_category ( a, b);
    }
  else
    {
      if ( b.reorg == NULL ) return false;
      if ( a.reorg < b.reorg ) return true;
      if ( a.reorg > b.reorg ) return false;
      // compare non_reorg_bit
      return acc_lt_acc_category ( a, b);
    }
}

static bool
acc_eq ( const acc_info_t& a, const acc_info_t& b )
{
  // nothing complicated is equal to anything else.  Being complicated
  // is basically saying that little is really know about it and it's
  // difficult if not meaningless to analyze in depth given this
  // framework.
  if ( a.base_info.complicated || b.base_info.complicated ) return false;
  if ( a.reorg != b.reorg ) return false;
  int ord_a = a.base_info.a_decl ? 1 : a.base_info.a_def_def ? 2 : 3;
  int ord_b = b.base_info.a_decl ? 1 : b.base_info.a_def_def ? 2 : 3;
  if ( ord_a != ord_b ) return false;
  switch ( ord_a ) {
  case 1:
  case 2:
    {
      if ( a.access != b.access ) return false;
    }
  case 3:
    {
      if ( a.base_info.function != b.base_info.function ) return false;
    }
  }
  return a.field == b.field;
}

static bool
all_but_field_eq ( const acc_info_t& a, const acc_info_t& b )
{
  // nothing complicated is equal to anything else.  Being complicated
  // is basically saying that little is really know about it and it's
  // difficult if not meaningless to analyze in depth given this
  // framework.
  if ( a.base_info.complicated || b.base_info.complicated ) return false;
  if ( a.reorg != b.reorg ) return false;
  int ord_a = a.base_info.a_decl ? 1 : a.base_info.a_def_def ? 2 : 3;
  int ord_b = b.base_info.a_decl ? 1 : b.base_info.a_def_def ? 2 : 3;
  if ( ord_a != ord_b ) return false;
  switch ( ord_a ) {
  case 1:
  case 2:
    {
      return a.access == b.access;
    }
  case 3:
    {
      return a.base_info.function == b.base_info.function;
    }
  }
}

#define SINGLE_POOL_SLOPE					\
  ((SINGLE_POOL_RAW_DO_IT_ALWAYS - SINGLE_POOL_RAW_SKIP_IT)	\
  /								\
   (SINGLE_POOL_ABS_DO_IT_ALWAYS - SINGLE_POOL_ABS_SKIP_IT))

#define SINGLE_POOL_INTERSECT		        \
  (SINGLE_POOL_RAW_SKIP_IT                      \
   -						\
   SINGLE_POOL_SLOPE * SINGLE_POOL_ABS_SKIP_IT)

static double
cut_off_eq_single_pool( double x)
{
  return SINGLE_POOL_SLOPE * x + SINGLE_POOL_INTERSECT;
}

static double
alignment_effect( unsigned HOST_WIDE_INT width )
{
  unsigned HOST_WIDE_INT times = param_l1_cache_line_size / width; // ??
  unsigned HOST_WIDE_INT rem   = param_l1_cache_line_size % width;
  if( rem == 0 ) {
    return 1.0;
  }
  unsigned HOST_WIDE_INT m, n, g;
  g = gcd( param_l1_cache_line_size, width);
  m = param_l1_cache_line_size / g;
  n = width / g;
  return 1.0 + (n - 1.0)/m;
}

static void
header ( bool initialize )
{
  static bool emit_header;
  if ( initialize )
    {
      emit_header = true;
    }
  else
    {
      if ( emit_header )
	{
	  emit_header = false;
	  fprintf( stderr, "SANITY CHECKING FAILURE:\n");
	}
    }
}

// TBD I have doubts that this what is really needed
bool
is_array_access( tree acc)
{
  tree type = TREE_TYPE ( acc);
  if( TREE_CODE( type) == ARRAY_TYPE )
    return true;
  while( POINTER_TYPE_P( type) ) {
    type = TREE_TYPE( type);
    if( TREE_CODE( type) == ARRAY_TYPE )
      return true;
  }
  return false;
}

static void
account_for_access ( tree access, tree field, std::vector <acc_info_t> *acc_info, Info_t *info)
{
  DEBUG_A("account_for_use var: ");
  DEBUG_F(flexible_print, stderr, access, 0, (dump_flags_t)0);
  DEBUG(", field: ");
  DEBUG_F(flexible_print, stderr, field, 1, (dump_flags_t)0);
  
  // assert might eventually make sense but not yet
  //gcc_assert ( TREE_CODE ( ssa_var) == SSA_NAME);
  acc_info_t ai;
  //ai.v = SSA_NAME_VAR ( ssa_var);
  ai.access = access; // TBD We need to see if we can find the decl
  ai.field = field;
  ai.reorg = tree_contains_a_reorgtype ( access, info);
  analyze_access ( access, &ai);
  // don't count this acces if there is no associated induction variable
  if ( !ai.base_info.has_induct_var_acc ) return;
  // Otherwise add the access
  acc_info->push_back( ai);
}

static void
tmasn_helper ( tree t, int indent, std::set<tree> *already )
{
  DEBUG_A("");
  fprintf( stderr, "%*s", indent, " ");
  indent += 4;
  flexible_print ( stderr, t, 0, (dump_flags_t)0);
  if ( already->find (t) != already->end () )
    {
      fprintf( stderr, " <Induction>\n");
      return;
    }
  else
    {
      fprintf( stderr, "\n");
    }
  DEBUG_L("code: %s\n", code_str(TREE_CODE (t)));
  if ( TREE_CODE (t) == SSA_NAME )
    {
      already->insert (t);
      gimple *stmt = SSA_NAME_DEF_STMT (t);
      fprintf( stderr, "%*sSSA_NAME defined in: ", indent - 4, " ");
      print_gimple_stmt( stderr, stmt, TDF_DETAILS);
      if ( gimple_code ( stmt) == GIMPLE_PHI )
	{
	  gphi *phi_stmt = dyn_cast <gphi *> ( stmt);
	  for (int i = 0; i < gimple_phi_num_args (phi_stmt); i++)
	    {
	      tree *arg = gimple_phi_arg_def_ptr (phi_stmt, i);
	      tmasn_helper ( *arg, indent, already);
	    }
	}
      else
	{
	  bool a_ass = gimple_code ( stmt) == GIMPLE_ASSIGN;
	  bool a_call = gimple_code ( stmt) == GIMPLE_CALL;
	  // This was being triggered an add: op = op + op
	  //gcc_assert ( a_ass || a_call );

	  if ( a_call )
	    {
	      for ( int i = 0; i < gimple_call_num_args ( stmt); i++ )
		{
		  tmasn_helper ( gimple_call_arg  ( stmt, i) , indent, already);
		}
	    }
	  else
	    {
	      // Note, start with one to skip lhs op. 
	      for ( int i = 1; i < gimple_num_ops ( stmt); i++ )
		{
		  tmasn_helper ( gimple_op ( stmt, i) , indent, already);
		}
	    }
	}
      return;
    }
  if ( DECL_P ( t) )
    {
      return;
    }
  if ( TREE_CODE ( t) == MEM_REF )
    {
      tree t_0 = TREE_OPERAND ( t, 0);
      fprintf( stderr, "%*sMEM_REF t_0: ", indent - 4, " ");
      flexible_print ( stderr, t_0, 1, (dump_flags_t)0);
      tmasn_helper ( t_0 , indent, already);
      return;
    }
  if ( TREE_CODE ( t) == INTEGER_CST ) return;
  fprintf ( stderr, "unanticipated TREE_CODE\n");
  gcc_assert ( 0);
}

static void
tell_me_about_ssa_name ( tree ssa_name, int indent)
{
  fprintf(stderr,"about:\n");
  std::set<tree> already;
  tmasn_helper ( ssa_name, indent, &already);
}

static void
an_ac_helper ( tree t, int indent, std::set<tree> *already, acc_info_t *ainfo )
{
  acc_base_info_t *binfo = &ainfo->base_info;
  DEBUG_A("%*s", indent, " ");
  indent += 4;
  DEBUG_F( flexible_print, stderr, t, 0, (dump_flags_t)0);
  if ( already->find (t) != already->end () )
    {
      DEBUG(" <Induction>\n");
      binfo->multi_induct =
	binfo->multi_induct || binfo->has_induct_var_acc;
      binfo->induct_base = t;
      binfo->has_induct_var_acc = true;
      return;
    }
  else
    {
      DEBUG("\n");
    }
  DEBUG_A("%*scode: %s\n", indent, " ", code_str(TREE_CODE (t)));
  if ( TREE_CODE (t) == SSA_NAME )
    {
      already->insert (t);
      gimple *stmt = SSA_NAME_DEF_STMT (t);
      DEBUG_A("%*sSSA_NAME defined in: ", indent, " ");
      DEBUG_F(print_gimple_stmt, stderr, stmt, TDF_DETAILS);
      if ( SSA_NAME_IS_DEFAULT_DEF ( t ) )
        {
	  binfo->acc_base = t;
	  binfo->complicated =
	    binfo->complicated || binfo->a_def_def || binfo->a_decl || binfo->a_func;
	  binfo->a_def_def = true;
	}
      if ( gimple_code ( stmt) == GIMPLE_PHI )
	{
	  gphi *phi_stmt = dyn_cast <gphi *> ( stmt);
	  for (int i = 0; i < gimple_phi_num_args (phi_stmt); i++)
	    {
	      tree *arg = gimple_phi_arg_def_ptr (phi_stmt, i);
	      an_ac_helper ( *arg, indent, already, ainfo);
	    }
	}
      else
	{
	  bool a_ass = gimple_code ( stmt) == GIMPLE_ASSIGN;
	  bool a_call = gimple_code ( stmt) == GIMPLE_CALL;
	  // This was being triggered an add: op = op + op
	  //gcc_assert ( a_ass || a_call );

	  if ( a_call )
	    {
	      binfo->acc_base = t;
	      binfo->complicated =
		binfo->complicated || binfo->a_def_def || binfo->a_decl || binfo->a_func;
	      binfo->a_func = true;
	      binfo->function = stmt;
	      // Question, do we want to walk the call arguements???
	      // Because how do the arguments effect the return value?
	      // It's basically unknow so we shouldn't walk the
	      // arguemets.
	      // 
	      for ( int i = 0; i < gimple_call_num_args ( stmt); i++ )
		{
		  an_ac_helper ( gimple_call_arg  ( stmt, i), indent, already, ainfo);
		}
	    }
	  else
	    {
	      // Note, start with one to skip lhs op. 
	      for ( int i = 1; i < gimple_num_ops ( stmt); i++ )
		{
		  an_ac_helper ( gimple_op ( stmt, i), indent, already, ainfo);
		}
	    }
	}
      return;
    }
  if ( DECL_P ( t) )
    {
      binfo->acc_base = t;
      binfo->complicated =
		binfo->complicated || binfo->a_def_def || binfo->a_decl || binfo->a_func;
      binfo->a_decl = true;
      
      DEBUG_A("field (index) for a_decl: ");
      DEBUG_F(flexible_print, stderr, ainfo->field, 1, (dump_flags_t)0);

      an_ac_helper ( ainfo->field, indent, already, ainfo);
      return;
    }
  if ( TREE_CODE ( t) == MEM_REF )
    {
      tree t_0 = TREE_OPERAND ( t, 0);
      DEBUG_A("%*sMEM_REF t_0: ", indent, " ");
      DEBUG_F(flexible_print, stderr, t_0, 1, (dump_flags_t)0);
      an_ac_helper ( t_0 , indent, already, ainfo);
      return;
    }
  if ( TREE_CODE ( t) == INTEGER_CST ) return;
  fprintf ( stderr, "Unanticipated TREE_CODE\n");
  gcc_assert ( 0);
}

static void
analyze_access ( tree access, acc_info_t *acc_info)
{
  acc_base_info_t *base_info = &acc_info->base_info;
  DEBUG_A("analyze_access:\n");
  base_info->a_def_def = false;
  base_info->a_decl = false;
  base_info->a_func = false;
  base_info->has_induct_var_acc = false;
  base_info->multi_induct = false;
  base_info->complicated = false;
  base_info->acc_base = NULL;
  base_info->induct_base = NULL;
  std::set<tree> already;
  an_ac_helper ( access, 4, &already, acc_info);
}


// create_new_types has to crawl "all" the
// types, create new types and transform
// other types that must be changed.
// A type will change when it's a
// a pointer to a ReorgType or it contains
// an interior pointer to one. 
static void
create_new_types ( Info_t *info)
{
  std::map < tree, BoolPair_t>::iterator tmi;
  for( tmi = info->struct_types->begin ();
       tmi != info->struct_types->end ();
       tmi++ ) {
    if ( !tmi->second.processed ) create_a_new_type ( info, tmi->first);
  }    
}

static void
create_a_new_type ( Info_t *info, tree type)
{
  bool layout_changed = false;
  // skip if already processed  		   
  if ( ( *( info->struct_types))[type].processed ) return;

  // Implementation note: Check this for infinite recursion.
  // I don't think it's possible in a sane universe but
  // pointers to reorganized types can occur, so does that
  // an issue (not necessarily here.)
  // Also, is this even necessary? Singletons don't expand
  // and static arrays are not allowed "yet."
  tree field;
  tree new_fields = NULL;
  for ( field = TYPE_FIELDS ( type); // ??? I speced reorg_type_prime here???
        field; 
        field = DECL_CHAIN ( field))
    {
      // make sure all the interior types are processed
      // before processing this type
      if ( TREE_CODE ( field) == RECORD_TYPE )
	{
	  create_a_new_type ( info, field);
	}
    }
	 
  ReorgType_t *ri = get_reorgtype_info ( type, info);
  if ( ri != NULL ) {
    // Create the new record type of the reorg type
    tree reorg_type_prime = lang_hooks.types.make_type (RECORD_TYPE);

    ri->reorg_ver_type = reorg_type_prime;
    //DEBUG_L("TYPE_SIZE(reorg_type_prime): %p, ", TYPE_SIZE(reorg_type_prime));
    //DEBUG_F( print_generic_expr, stderr, TYPE_SIZE(reorg_type_prime), (dump_flags_t)-1);
    //DEBUG("\n");
    
    /* Multi-pool only
    // Create pointer_rep
    // this will be a long and a pointer to the 
    // reorg_type_prime
    tree pointer_rep = 
    lang_hooks.types.make_type( RECORD_TYPE);
    
    tree index_name = get_identifier("index");
    tree index_field = build_decl( BUILTINS_LOCATION, 
    FIELD_DECL, 
    index_name, 
    long_integer_type_node);
    tree base_name = get_identifier("base");
    tree base_field = build_decl( BUILTINS_LOCATION, 
    FIELD_DECL, 
    base_name, 
    reorg_type_prime);
    insert_field_into_struct( pointer_rep, index_field);
    insert_field_into_struct( pointer_rep, base);
    
    reorg_type->pointer_rep = pointer_rep;
    */

    tree pointer_rep = make_signed_type ( TYPE_PRECISION ( pointer_sized_int_node));
    TYPE_MAIN_VARIANT ( pointer_rep) = TYPE_MAIN_VARIANT ( pointer_sized_int_node);
    //DEBUG("Issue with gcc_ of reorg\n");
    //DEBUG_F(print_reorg, stderr, 2, ri);
    const char *gcc_name =
      identifier_to_locale ( IDENTIFIER_POINTER ( TYPE_NAME ( ri->gcc_type)));
    size_t len =
      strlen ( REORG_SP_PTR_PREFIX) + strlen ( gcc_name);
    char *name = ( char *)alloca(len + 1);
    strcpy ( name, REORG_SP_PTR_PREFIX);
    strcat ( name, gcc_name);
    TYPE_NAME ( pointer_rep) = get_identifier ( name);
    ri->pointer_rep = pointer_rep;
    //DEBUG_L("pointer_rep = ");
    //DEBUG_F( print_generic_expr, stderr, pointer_rep, (dump_flags_t)-1);
    //DEBUG("\n");
    //DEBUG_A("TYPE_MAIN_VARIANT ( pointer_rep) = ");
    //DEBUG_F( print_generic_expr, stderr, TYPE_MAIN_VARIANT ( pointer_rep), (dump_flags_t)-1);
    //DEBUG("\n");

    // Note, we also declare a base type variable (globally.)
    // This variable also belong in the ReorgType.
    
    // Set name of reorg_type_prime
    const char *base_type_name =
      identifier_to_locale ( IDENTIFIER_POINTER ( TYPE_NAME ( ri->gcc_type)));
    len = strlen ( REORG_SP_PREFIX) + strlen ( base_type_name);
    char *rec_name = ( char*)alloca ( len + 1);
    strcpy ( rec_name, REORG_SP_PREFIX);
    strcat ( rec_name, base_type_name);
    
    //DEBUG_L("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
    
    // Build the new pointer type fields
    TYPE_NAME ( reorg_type_prime) = get_identifier ( rec_name);
    tree field;
    tree new_fields = NULL;
    for ( field = TYPE_FIELDS ( type); field; field = DECL_CHAIN ( field))
      {
	//DEBUG_F( print_generic_decl, stderr, field, TDF_DETAILS); // example
	tree tree_type = TREE_TYPE ( field);
	tree new_fld_type = build_pointer_type ( tree_type);
	tree new_decl =
	  build_decl ( DECL_SOURCE_LOCATION (field),
		       FIELD_DECL, DECL_NAME (field), new_fld_type);
	DECL_CONTEXT ( new_decl) = reorg_type_prime;
	layout_decl ( new_decl, 0);
	
	// We might be missing a bunch of attributes (see
	// tree-nested.c:899) But we seem without without them!
	
	DECL_CHAIN ( new_decl) = new_fields; // <- bug: need decl, not type
	new_fields = new_decl;
	//DEBUG( "built new pointer type field:");
	//DEBUG_F( print_generic_decl, stderr, new_decl, TDF_DETAILS);
	//DEBUG( "\n");
      }

    //DEBUG_L("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
    
    // store reversed fields into reorg_type_prime
    TYPE_FIELDS ( reorg_type_prime) = NULL;
    tree next_fld;
    for ( field = new_fields;
	  field; 
	  field = next_fld    )
      {
	next_fld = DECL_CHAIN ( field);
	DECL_CHAIN ( field) = TYPE_FIELDS ( reorg_type_prime);
	TYPE_FIELDS ( reorg_type_prime) = field;
      }
    //DEBUG_L("TYPE_SIZE(reorg_type_prime): %p\n", TYPE_SIZE(reorg_type_prime));
    // Fix-up the layout
    layout_type ( reorg_type_prime);

    // HERE
    // Create the base element for a reorg type. This is for the single
    // pool case only.
    tree base_var =
      build_decl ( UNKNOWN_LOCATION, VAR_DECL, NULL_TREE, ri->reorg_ver_type);
    // We don't want to manually set DECL_INITIAL here!
    
    const char *type_name =
      identifier_to_locale ( IDENTIFIER_POINTER ( TYPE_NAME ( ri->gcc_type)));
    size_t tlen = strlen ( REORG_SP_BASE_PREFIX) + strlen ( type_name);
    char *base_name = ( char*)alloca ( tlen + 1);
    strcpy ( base_name, REORG_SP_BASE_PREFIX);
    //DECL_NAME ( base_var) = get_identifier ( base_name);
    
    strcat ( base_name, type_name);
    
    DECL_NAME ( base_var) = get_identifier ( base_name); // wrong spot above???
    
    TREE_STATIC ( base_var) = 1;
    TREE_ADDRESSABLE  ( base_var) = 1;
    DECL_NONALIASED ( base_var) = 1;
    SET_DECL_ALIGN ( base_var, TYPE_ALIGN ( ri->reorg_ver_type));
    
    varpool_node::finalize_decl ( base_var);

    relayout_decl ( base_var);
    
    ri->instance_interleave.base = base_var;
  }

  // Mess with the original type too because it might
  // have base_type_fldinterior elements that are modified.
  for ( field = TYPE_FIELDS ( type); 
       field; 
       field = DECL_CHAIN ( field))
    {
      if ( TREE_CODE ( field) == RECORD_TYPE )
	{
	  layout_changed =
	    layout_changed || ( *( info->struct_types)) [ field].layout_changed;
	}
      else
	{
	  // process pointers to reorg types
	  if ( POINTER_TYPE_P ( field) )
	    {
	      tree field_type = TREE_TYPE ( field);
	      if ( is_reorg_type ( field_type, info) )
		{
		  // Change field type.
		  
		  // If multi-pool then set layout_changed to true.
		  
		  // The type pointed to changes for single-pool.
		  ReorgType_t *ri =
		    get_reorgtype_info ( field_type, info);
		  gcc_assert ( ri->pointer_rep);
		  TREE_TYPE ( field) = ri->pointer_rep;
		}
	      tree base = base_type_of ( field);
	      if ( is_reorg_type ( base, info) )
		{
		  // strip off a layer of pointers
		  gcc_assert ( TREE_TYPE ( TREE_TYPE( field)));
		  TREE_TYPE ( field) = TREE_TYPE ( TREE_TYPE( field));
		}
	    }
	}
    }

  // Mark the type as processed
  ( *( info->struct_types)) [ type] = { true, layout_changed};
}

static tree
find_coresponding_field ( tree base_decl, tree field)
{
  tree reorg_field;
  for ( reorg_field = TYPE_FIELDS ( TREE_TYPE ( base_decl)); 
	 reorg_field; 
	 reorg_field = DECL_CHAIN ( reorg_field))
      {
	const char *reorg_field_name =
	  lang_hooks.decl_printable_name ( reorg_field, 2);
	const char *field_name =
	  lang_hooks.decl_printable_name ( field, 2);
	//DEBUG_L("LOOK %s, %s\n", reorg_field_name, field_name);
	
	if ( strcmp ( reorg_field_name, field_name) == 0 )
	  {
	    gcc_assert ( TREE_TYPE( field) == TREE_TYPE( TREE_TYPE(reorg_field)));
	    return reorg_field;
	  }
      }
  internal_error ( "find_coresponding_field: found no field");
}

static void
remove_default_def ( tree default_def, struct function *func)
{
  size_t i;
  tree ssa_name;
  FOR_EACH_SSA_NAME ( i, ssa_name, func)
    {
      if ( default_def == ssa_name )
	{
	  SSANAMES ( func)->unordered_remove ( i);
	  return;
	}
    }
}

static basic_block
make_bb ( char *msg, basic_block prev_bb )
{
  basic_block ret = create_empty_bb ( prev_bb);
  DEBUG_A( "make_bb ( %s, <bb %d>/%p  ): <bb %d>/%p, prev: <bb %d>/%p, next: <bb %d>/%p\n",
	   msg, prev_bb->index, prev_bb,
	   ret->index, ret,
	   ret->prev_bb->index, ret->prev_bb,
	   ret->next_bb->index, ret->next_bb);
  return ret;
}