aboutsummaryrefslogtreecommitdiff
BranchCommit messageAuthorAge
alpha-portsome infoHelge Deller2 years
bigfontparisc/STI: Add TER16x32 fontHelge Deller3 years
develupdateHelge Deller3 months
devel-2022parisc: Add opt/hostid fw_cfg option to change hostidHelge Deller3 years
devel-4-do-not-usepdc update und boot disc rewriteHelge Deller10 months
devel-btlbbtlb: Fix all, everything ok.Helge Deller11 months
devel-btlb-2parisc: SEABIOS_HPPA_VERSION 9Helge Deller11 months
devel-last-for-v16Linux boots again on all.Helge Deller7 months
devel-with-sti64bitparisc: Remove exec flag from hppa-firmware.imgHelge Deller4 months
devel2small cleanupsHelge Deller10 months
devel3convert to new pdc.hHelge Deller10 months
devel4parisc: ad .vimrc editor helper fileHelge Deller10 months
devel5parisc: SEABIOS_HPPA_VERSION 10Helge Deller10 months
devel64parisc: Detect Astro Runway port and CPUsHelge Deller10 months
hp3000parisc: Identing updatesHelge Deller22 months
hp3000-consoletemp workHelge Deller21 months
hppa-reboot-fixparisc: SEABIOS_HPPA_VERSION 8Helge Deller14 months
hppa-targetata.c: Add missing endianess conversion functionsHelge Deller4 years
hppa-target-2parisc: Increase SEABIOS_HPPA_VERSION to version 2Helge Deller3 years
masterparisc: Fix 64-bit PDC call to not trash %dpHelge Deller6 months
master-new-v7parisc: SEABIOS_HPPA_VERSION 7Helge Deller14 months
master-oldparisc: Alloc any font size with STI font_unpmv functionHelge Deller4 years
parisc-qemu-4.1.0Merge pull request #4 from svenschnelle/parisc-qemu-4.1.0Helge Deller5 years
parisc-qemu-5.0parisc: Add soft power switch button emulation for QEMUHelge Deller4 years
parisc-qemu-5.1parisc: Move power switch button to firmware areaHelge Deller4 years
parisc-qemu-5.1-nextparisc: Make power switch button configurable from qemuHelge Deller4 years
parisc-qemu-6parisc: Increase SEABIOS_HPPA_VERSION to version 2Helge Deller3 years
parisc_firmwareImprove debug messages, code indenting, TOD accuracyHelge Deller5 years
seabios-hppa-v3-rcparisc: SEABIOS_HPPA_VERSION 3Helge Deller3 years
seabios-hppa-v3-rc2parisc: SEABIOS_HPPA_VERSION 3Helge Deller3 years
serial-port-fix-testparisc: SEABIOS_HPPA_VERSION 6Helge Deller2 years
toc-supportparisc: SEABIOS_HPPA_VERSION 3Helge Deller3 years
upstreamtcgbios: Disable platform hierarchy in case of failureStefan Berger3 years
v6-testparisc: SEABIOS_HPPA_VERSION 6Helge Deller2 years
 
TagDownloadAuthorAge
seabios-hppa-v15seabios-hppa-v15.zip  seabios-hppa-v15.tar.gz  seabios-hppa-v15.tar.bz2  Helge Deller7 months
seabios-hppa-v14seabios-hppa-v14.zip  seabios-hppa-v14.tar.gz  seabios-hppa-v14.tar.bz2  Helge Deller7 months
seabios-hppa-v13seabios-hppa-v13.zip  seabios-hppa-v13.tar.gz  seabios-hppa-v13.tar.bz2  Helge Deller9 months
seabios-hppa-v12seabios-hppa-v12.zip  seabios-hppa-v12.tar.gz  seabios-hppa-v12.tar.bz2  Helge Deller9 months
seabios-hppa-v10seabios-hppa-v10.zip  seabios-hppa-v10.tar.gz  seabios-hppa-v10.tar.bz2  Helge Deller10 months
seabios-hppa-v9seabios-hppa-v9.zip  seabios-hppa-v9.tar.gz  seabios-hppa-v9.tar.bz2  Helge Deller11 months
seabios-hppa-v8seabios-hppa-v8.zip  seabios-hppa-v8.tar.gz  seabios-hppa-v8.tar.bz2  Helge Deller14 months
seabios-hppa-v7seabios-hppa-v7.zip  seabios-hppa-v7.tar.gz  seabios-hppa-v7.tar.bz2  Helge Deller14 months
seabios-hppa-v6seabios-hppa-v6.zip  seabios-hppa-v6.tar.gz  seabios-hppa-v6.tar.bz2  Helge Deller2 years
seabios-hppa-v5seabios-hppa-v5.zip  seabios-hppa-v5.tar.gz  seabios-hppa-v5.tar.bz2  Helge Deller2 years
seabios-hppa-v4seabios-hppa-v4.zip  seabios-hppa-v4.tar.gz  seabios-hppa-v4.tar.bz2  Helge Deller2 years
seabios-hppa-v3seabios-hppa-v3.zip  seabios-hppa-v3.tar.gz  seabios-hppa-v3.tar.bz2  Helge Deller3 years
seabios-hppa-v2seabios-hppa-v2.zip  seabios-hppa-v2.tar.gz  seabios-hppa-v2.tar.bz2  Helge Deller3 years
hppa-qemu-5.2-2seabios-hppa-hppa-qemu-5.2-2.zip  seabios-hppa-hppa-qemu-5.2-2.tar.gz  seabios-hppa-hppa-qemu-5.2-2.tar.bz2  Helge Deller4 years
hppa-qemu-5.2-1seabios-hppa-hppa-qemu-5.2-1.zip  seabios-hppa-hppa-qemu-5.2-1.tar.gz  seabios-hppa-hppa-qemu-5.2-1.tar.bz2  Helge Deller4 years
rel-1.10.2seabios-hppa-rel-1.10.2.zip  seabios-hppa-rel-1.10.2.tar.gz  seabios-hppa-rel-1.10.2.tar.bz2  Ben Warren7 years
rel-1.10.1seabios-hppa-rel-1.10.1.zip  seabios-hppa-rel-1.10.1.tar.gz  seabios-hppa-rel-1.10.1.tar.bz2  Igor Mammedov8 years
rel-1.10.0seabios-hppa-rel-1.10.0.zip  seabios-hppa-rel-1.10.0.tar.gz  seabios-hppa-rel-1.10.0.tar.bz2  Kevin O'Connor8 years
rel-1.9.3seabios-hppa-rel-1.9.3.zip  seabios-hppa-rel-1.9.3.tar.gz  seabios-hppa-rel-1.9.3.tar.bz2  Haozhong Zhang8 years
rel-1.9.2seabios-hppa-rel-1.9.2.zip  seabios-hppa-rel-1.9.2.tar.gz  seabios-hppa-rel-1.9.2.tar.bz2  Marcel Apfelbaum8 years
rel-1.9.1seabios-hppa-rel-1.9.1.zip  seabios-hppa-rel-1.9.1.tar.gz  seabios-hppa-rel-1.9.1.tar.bz2  Cole Robinson9 years
rel-1.9.0seabios-hppa-rel-1.9.0.zip  seabios-hppa-rel-1.9.0.tar.gz  seabios-hppa-rel-1.9.0.tar.bz2  Kevin O'Connor9 years
rel-1.8.2seabios-hppa-rel-1.8.2.zip  seabios-hppa-rel-1.8.2.tar.gz  seabios-hppa-rel-1.8.2.tar.bz2  Kevin O'Connor9 years
rel-1.8.1seabios-hppa-rel-1.8.1.zip  seabios-hppa-rel-1.8.1.tar.gz  seabios-hppa-rel-1.8.1.tar.bz2  Kevin O'Connor9 years
rel-1.8.0seabios-hppa-rel-1.8.0.zip  seabios-hppa-rel-1.8.0.tar.gz  seabios-hppa-rel-1.8.0.tar.bz2  Kevin O'Connor10 years
rel-1.7.5.2seabios-hppa-rel-1.7.5.2.zip  seabios-hppa-rel-1.7.5.2.tar.gz  seabios-hppa-rel-1.7.5.2.tar.bz2  Kevin O'Connor10 years
rel-1.7.5.1seabios-hppa-rel-1.7.5.1.zip  seabios-hppa-rel-1.7.5.1.tar.gz  seabios-hppa-rel-1.7.5.1.tar.bz2  Hannes Reinecke10 years
rel-1.7.5seabios-hppa-rel-1.7.5.zip  seabios-hppa-rel-1.7.5.tar.gz  seabios-hppa-rel-1.7.5.tar.bz2  Kevin O'Connor10 years
rel-1.7.5-rc1seabios-hppa-rel-1.7.5-rc1.zip  seabios-hppa-rel-1.7.5-rc1.tar.gz  seabios-hppa-rel-1.7.5-rc1.tar.bz2  Kevin O'Connor10 years
rel-1.7.4seabios-hppa-rel-1.7.4.zip  seabios-hppa-rel-1.7.4.tar.gz  seabios-hppa-rel-1.7.4.tar.bz2  Kevin O'Connor11 years
rel-1.7.3.2seabios-hppa-rel-1.7.3.2.zip  seabios-hppa-rel-1.7.3.2.tar.gz  seabios-hppa-rel-1.7.3.2.tar.bz2  Gerd Hoffmann11 years
rel-1.7.3.1seabios-hppa-rel-1.7.3.1.zip  seabios-hppa-rel-1.7.3.1.tar.gz  seabios-hppa-rel-1.7.3.1.tar.bz2  Kevin O'Connor11 years
rel-1.7.3seabios-hppa-rel-1.7.3.zip  seabios-hppa-rel-1.7.3.tar.gz  seabios-hppa-rel-1.7.3.tar.bz2  Kevin O'Connor11 years
rel-1.7.2.2seabios-hppa-rel-1.7.2.2.zip  seabios-hppa-rel-1.7.2.2.tar.gz  seabios-hppa-rel-1.7.2.2.tar.bz2  Kevin O'Connor11 years
rel-1.7.2.1seabios-hppa-rel-1.7.2.1.zip  seabios-hppa-rel-1.7.2.1.tar.gz  seabios-hppa-rel-1.7.2.1.tar.bz2  Alex Williamson11 years
rel-1.7.2seabios-hppa-rel-1.7.2.zip  seabios-hppa-rel-1.7.2.tar.gz  seabios-hppa-rel-1.7.2.tar.bz2  Paolo Bonzini12 years
rel-1.7.1seabios-hppa-rel-1.7.1.zip  seabios-hppa-rel-1.7.1.tar.gz  seabios-hppa-rel-1.7.1.tar.bz2  Kevin O'Connor12 years
rel-1.7.0seabios-hppa-rel-1.7.0.zip  seabios-hppa-rel-1.7.0.tar.gz  seabios-hppa-rel-1.7.0.tar.bz2  Kevin O'Connor12 years
rel-1.6.3.2seabios-hppa-rel-1.6.3.2.zip  seabios-hppa-rel-1.6.3.2.tar.gz  seabios-hppa-rel-1.6.3.2.tar.bz2  Kevin O'Connor12 years
rel-1.6.3.1seabios-hppa-rel-1.6.3.1.zip  seabios-hppa-rel-1.6.3.1.tar.gz  seabios-hppa-rel-1.6.3.1.tar.bz2  Kevin O'Connor13 years
rel-1.6.3seabios-hppa-rel-1.6.3.zip  seabios-hppa-rel-1.6.3.tar.gz  seabios-hppa-rel-1.6.3.tar.bz2  Kevin O'Connor13 years
rel-0.6.2seabios-hppa-rel-0.6.2.zip  seabios-hppa-rel-0.6.2.tar.gz  seabios-hppa-rel-0.6.2.tar.bz2  Kevin O'Connor13 years
rel-0.6.1.3seabios-hppa-rel-0.6.1.3.zip  seabios-hppa-rel-0.6.1.3.tar.gz  seabios-hppa-rel-0.6.1.3.tar.bz2  Kevin O'Connor14 years
rel-0.6.1.2seabios-hppa-rel-0.6.1.2.zip  seabios-hppa-rel-0.6.1.2.tar.gz  seabios-hppa-rel-0.6.1.2.tar.bz2  Kevin O'Connor14 years
rel-0.6.1.1seabios-hppa-rel-0.6.1.1.zip  seabios-hppa-rel-0.6.1.1.tar.gz  seabios-hppa-rel-0.6.1.1.tar.bz2  Kevin O'Connor14 years
rel-0.6.1seabios-hppa-rel-0.6.1.zip  seabios-hppa-rel-0.6.1.tar.gz  seabios-hppa-rel-0.6.1.tar.bz2  Kevin O'Connor14 years
rel-0.6.0seabios-hppa-rel-0.6.0.zip  seabios-hppa-rel-0.6.0.tar.gz  seabios-hppa-rel-0.6.0.tar.bz2  Kevin O'Connor14 years
rel-0.5.1seabios-hppa-rel-0.5.1.zip  seabios-hppa-rel-0.5.1.tar.gz  seabios-hppa-rel-0.5.1.tar.bz2  Kevin O'Connor15 years
rel-0.5.0seabios-hppa-rel-0.5.0.zip  seabios-hppa-rel-0.5.0.tar.gz  seabios-hppa-rel-0.5.0.tar.bz2  Kevin O'Connor15 years
rel-0.4.2seabios-hppa-rel-0.4.2.zip  seabios-hppa-rel-0.4.2.tar.gz  seabios-hppa-rel-0.4.2.tar.bz2  Kevin O'Connor15 years
rel-0.4.1seabios-hppa-rel-0.4.1.zip  seabios-hppa-rel-0.4.1.tar.gz  seabios-hppa-rel-0.4.1.tar.bz2  Kevin O'Connor15 years
rel-0.4.0seabios-hppa-rel-0.4.0.zip  seabios-hppa-rel-0.4.0.tar.gz  seabios-hppa-rel-0.4.0.tar.bz2  Kevin O'Connor16 years
rel-0.3.0seabios-hppa-rel-0.3.0.zip  seabios-hppa-rel-0.3.0.tar.gz  seabios-hppa-rel-0.3.0.tar.bz2  Kevin O'Connor16 years
rel-0.2.3seabios-hppa-rel-0.2.3.zip  seabios-hppa-rel-0.2.3.tar.gz  seabios-hppa-rel-0.2.3.tar.bz2  Kevin O'Connor16 years
rel-0.2.2seabios-hppa-rel-0.2.2.zip  seabios-hppa-rel-0.2.2.tar.gz  seabios-hppa-rel-0.2.2.tar.bz2  Kevin O'Connor16 years
rel-0.2.1seabios-hppa-rel-0.2.1.zip  seabios-hppa-rel-0.2.1.tar.gz  seabios-hppa-rel-0.2.1.tar.bz2  Kevin O'Connor16 years
rel-0.2.0seabios-hppa-rel-0.2.0.zip  seabios-hppa-rel-0.2.0.tar.gz  seabios-hppa-rel-0.2.0.tar.bz2  Kevin O'Connor16 years
rel-0.1.3seabios-hppa-rel-0.1.3.zip  seabios-hppa-rel-0.1.3.tar.gz  seabios-hppa-rel-0.1.3.tar.bz2  Kevin O'Connor16 years
rel-0.1.2seabios-hppa-rel-0.1.2.zip  seabios-hppa-rel-0.1.2.tar.gz  seabios-hppa-rel-0.1.2.tar.bz2  Kevin O'Connor16 years
rel-0.1.1seabios-hppa-rel-0.1.1.zip  seabios-hppa-rel-0.1.1.tar.gz  seabios-hppa-rel-0.1.1.tar.bz2  Kevin O'Connor16 years
rel-0.1.0seabios-hppa-rel-0.1.0.zip  seabios-hppa-rel-0.1.0.tar.gz  seabios-hppa-rel-0.1.0.tar.bz2  Kevin O'Connor16 years
href='#n1845'>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
/* Move registers around to reduce number of move instructions needed.
   Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.

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 2, 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 COPYING.  If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.  */


/* This module looks for cases where matching constraints would force
   an instruction to need a reload, and this reload would be a register
   to register move.  It then attempts to change the registers used by the
   instruction to avoid the move instruction.  */

#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h" /* stdio.h must precede rtl.h for FFS.  */
#include "tm_p.h"
#include "insn-config.h"
#include "recog.h"
#include "output.h"
#include "regs.h"
#include "hard-reg-set.h"
#include "flags.h"
#include "function.h"
#include "expr.h"
#include "basic-block.h"
#include "except.h"
#include "toplev.h"
#include "reload.h"


/* Turn STACK_GROWS_DOWNWARD into a boolean.  */
#ifdef STACK_GROWS_DOWNWARD
#undef STACK_GROWS_DOWNWARD
#define STACK_GROWS_DOWNWARD 1
#else
#define STACK_GROWS_DOWNWARD 0
#endif

static int perhaps_ends_bb_p (rtx);
static int optimize_reg_copy_1 (rtx, rtx, rtx);
static void optimize_reg_copy_2 (rtx, rtx, rtx);
static void optimize_reg_copy_3 (rtx, rtx, rtx);
static void copy_src_to_dest (rtx, rtx, rtx, int);
static int *regmove_bb_head;

struct match {
  int with[MAX_RECOG_OPERANDS];
  enum { READ, WRITE, READWRITE } use[MAX_RECOG_OPERANDS];
  int commutative[MAX_RECOG_OPERANDS];
  int early_clobber[MAX_RECOG_OPERANDS];
};

static rtx discover_flags_reg (void);
static void mark_flags_life_zones (rtx);
static void flags_set_1 (rtx, rtx, void *);

static int try_auto_increment (rtx, rtx, rtx, rtx, HOST_WIDE_INT, int);
static int find_matches (rtx, struct match *);
static void replace_in_call_usage (rtx *, unsigned int, rtx, rtx);
static int fixup_match_1 (rtx, rtx, rtx, rtx, rtx, int, int, int, FILE *);
static int reg_is_remote_constant_p (rtx, rtx, rtx);
static int stable_and_no_regs_but_for_p (rtx, rtx, rtx);
static int regclass_compatible_p (int, int);
static int replacement_quality (rtx);
static int fixup_match_2 (rtx, rtx, rtx, rtx, FILE *);

/* Return nonzero if registers with CLASS1 and CLASS2 can be merged without
   causing too much register allocation problems.  */
static int
regclass_compatible_p (int class0, int class1)
{
  return (class0 == class1
	  || (reg_class_subset_p (class0, class1)
	      && ! CLASS_LIKELY_SPILLED_P (class0))
	  || (reg_class_subset_p (class1, class0)
	      && ! CLASS_LIKELY_SPILLED_P (class1)));
}

/* INC_INSN is an instruction that adds INCREMENT to REG.
   Try to fold INC_INSN as a post/pre in/decrement into INSN.
   Iff INC_INSN_SET is nonzero, inc_insn has a destination different from src.
   Return nonzero for success.  */
static int
try_auto_increment (rtx insn, rtx inc_insn, rtx inc_insn_set, rtx reg,
		    HOST_WIDE_INT increment, int pre)
{
  enum rtx_code inc_code;

  rtx pset = single_set (insn);
  if (pset)
    {
      /* Can't use the size of SET_SRC, we might have something like
	 (sign_extend:SI (mem:QI ...  */
      rtx use = find_use_as_address (pset, reg, 0);
      if (use != 0 && use != (rtx) (size_t) 1)
	{
	  int size = GET_MODE_SIZE (GET_MODE (use));
	  if (0
	      || (HAVE_POST_INCREMENT
		  && pre == 0 && (inc_code = POST_INC, increment == size))
	      || (HAVE_PRE_INCREMENT
		  && pre == 1 && (inc_code = PRE_INC, increment == size))
	      || (HAVE_POST_DECREMENT
		  && pre == 0 && (inc_code = POST_DEC, increment == -size))
	      || (HAVE_PRE_DECREMENT
		  && pre == 1 && (inc_code = PRE_DEC, increment == -size))
	  )
	    {
	      if (inc_insn_set)
		validate_change
		  (inc_insn,
		   &SET_SRC (inc_insn_set),
		   XEXP (SET_SRC (inc_insn_set), 0), 1);
	      validate_change (insn, &XEXP (use, 0),
			       gen_rtx_fmt_e (inc_code, Pmode, reg), 1);
	      if (apply_change_group ())
		{
		  /* If there is a REG_DEAD note on this insn, we must
		     change this not to REG_UNUSED meaning that the register
		     is set, but the value is dead.  Failure to do so will
		     result in a sched1 abort -- when it recomputes lifetime
		     information, the number of REG_DEAD notes will have
		     changed.  */
		  rtx note = find_reg_note (insn, REG_DEAD, reg);
		  if (note)
		    PUT_MODE (note, REG_UNUSED);

		  REG_NOTES (insn)
		    = gen_rtx_EXPR_LIST (REG_INC,
					 reg, REG_NOTES (insn));
		  if (! inc_insn_set)
		    delete_insn (inc_insn);
		  return 1;
		}
	    }
	}
    }
  return 0;
}

/* Determine if the pattern generated by add_optab has a clobber,
   such as might be issued for a flags hard register.  To make the
   code elsewhere simpler, we handle cc0 in this same framework.

   Return the register if one was discovered.  Return NULL_RTX if
   if no flags were found.  Return pc_rtx if we got confused.  */

static rtx
discover_flags_reg (void)
{
  rtx tmp;
  tmp = gen_rtx_REG (word_mode, 10000);
  tmp = gen_add3_insn (tmp, tmp, const2_rtx);

  /* If we get something that isn't a simple set, or a
     [(set ..) (clobber ..)], this whole function will go wrong.  */
  if (GET_CODE (tmp) == SET)
    return NULL_RTX;
  else if (GET_CODE (tmp) == PARALLEL)
    {
      int found;

      if (XVECLEN (tmp, 0) != 2)
	return pc_rtx;
      tmp = XVECEXP (tmp, 0, 1);
      if (GET_CODE (tmp) != CLOBBER)
	return pc_rtx;
      tmp = XEXP (tmp, 0);

      /* Don't do anything foolish if the md wanted to clobber a
	 scratch or something.  We only care about hard regs.
	 Moreover we don't like the notion of subregs of hard regs.  */
      if (GET_CODE (tmp) == SUBREG
	  && REG_P (SUBREG_REG (tmp))
	  && REGNO (SUBREG_REG (tmp)) < FIRST_PSEUDO_REGISTER)
	return pc_rtx;
      found = (REG_P (tmp) && REGNO (tmp) < FIRST_PSEUDO_REGISTER);

      return (found ? tmp : NULL_RTX);
    }

  return pc_rtx;
}

/* It is a tedious task identifying when the flags register is live and
   when it is safe to optimize.  Since we process the instruction stream
   multiple times, locate and record these live zones by marking the
   mode of the instructions --

   QImode is used on the instruction at which the flags becomes live.

   HImode is used within the range (exclusive) that the flags are
   live.  Thus the user of the flags is not marked.

   All other instructions are cleared to VOIDmode.  */

/* Used to communicate with flags_set_1.  */
static rtx flags_set_1_rtx;
static int flags_set_1_set;

static void
mark_flags_life_zones (rtx flags)
{
  int flags_regno;
  int flags_nregs;
  basic_block block;

#ifdef HAVE_cc0
  /* If we found a flags register on a cc0 host, bail.  */
  if (flags == NULL_RTX)
    flags = cc0_rtx;
  else if (flags != cc0_rtx)
    flags = pc_rtx;
#endif

  /* Simple cases first: if no flags, clear all modes.  If confusing,
     mark the entire function as being in a flags shadow.  */
  if (flags == NULL_RTX || flags == pc_rtx)
    {
      enum machine_mode mode = (flags ? HImode : VOIDmode);
      rtx insn;
      for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
	PUT_MODE (insn, mode);
      return;
    }

#ifdef HAVE_cc0
  flags_regno = -1;
  flags_nregs = 1;
#else
  flags_regno = REGNO (flags);
  flags_nregs = hard_regno_nregs[flags_regno][GET_MODE (flags)];
#endif
  flags_set_1_rtx = flags;

  /* Process each basic block.  */
  FOR_EACH_BB_REVERSE (block)
    {
      rtx insn, end;
      int live;

      insn = BB_HEAD (block);
      end = BB_END (block);

      /* Look out for the (unlikely) case of flags being live across
	 basic block boundaries.  */
      live = 0;
#ifndef HAVE_cc0
      {
	int i;
	for (i = 0; i < flags_nregs; ++i)
	  live |= REGNO_REG_SET_P (block->global_live_at_start,
				   flags_regno + i);
      }
#endif

      while (1)
	{
	  /* Process liveness in reverse order of importance --
	     alive, death, birth.  This lets more important info
	     overwrite the mode of lesser info.  */

	  if (INSN_P (insn))
	    {
#ifdef HAVE_cc0
	      /* In the cc0 case, death is not marked in reg notes,
		 but is instead the mere use of cc0 when it is alive.  */
	      if (live && reg_mentioned_p (cc0_rtx, PATTERN (insn)))
		live = 0;
#else
	      /* In the hard reg case, we watch death notes.  */
	      if (live && find_regno_note (insn, REG_DEAD, flags_regno))
		live = 0;
#endif
	      PUT_MODE (insn, (live ? HImode : VOIDmode));

	      /* In either case, birth is denoted simply by its presence
		 as the destination of a set.  */
	      flags_set_1_set = 0;
	      note_stores (PATTERN (insn), flags_set_1, NULL);
	      if (flags_set_1_set)
		{
		  live = 1;
		  PUT_MODE (insn, QImode);
		}
	    }
	  else
	    PUT_MODE (insn, (live ? HImode : VOIDmode));

	  if (insn == end)
	    break;
	  insn = NEXT_INSN (insn);
	}
    }
}

/* A subroutine of mark_flags_life_zones, called through note_stores.  */

static void
flags_set_1 (rtx x, rtx pat, void *data ATTRIBUTE_UNUSED)
{
  if (GET_CODE (pat) == SET
      && reg_overlap_mentioned_p (x, flags_set_1_rtx))
    flags_set_1_set = 1;
}

static int *regno_src_regno;

/* Indicate how good a choice REG (which appears as a source) is to replace
   a destination register with.  The higher the returned value, the better
   the choice.  The main objective is to avoid using a register that is
   a candidate for tying to a hard register, since the output might in
   turn be a candidate to be tied to a different hard register.  */
static int
replacement_quality (rtx reg)
{
  int src_regno;

  /* Bad if this isn't a register at all.  */
  if (!REG_P (reg))
    return 0;

  /* If this register is not meant to get a hard register,
     it is a poor choice.  */
  if (REG_LIVE_LENGTH (REGNO (reg)) < 0)
    return 0;

  src_regno = regno_src_regno[REGNO (reg)];

  /* If it was not copied from another register, it is fine.  */
  if (src_regno < 0)
    return 3;

  /* Copied from a hard register?  */
  if (src_regno < FIRST_PSEUDO_REGISTER)
    return 1;

  /* Copied from a pseudo register - not as bad as from a hard register,
     yet still cumbersome, since the register live length will be lengthened
     when the registers get tied.  */
  return 2;
}

/* Return 1 if INSN might end a basic block.  */

static int perhaps_ends_bb_p (rtx insn)
{
  switch (GET_CODE (insn))
    {
    case CODE_LABEL:
    case JUMP_INSN:
      /* These always end a basic block.  */
      return 1;

    case CALL_INSN:
      /* A CALL_INSN might be the last insn of a basic block, if it is inside
	 an EH region or if there are nonlocal gotos.  Note that this test is
	 very conservative.  */
      if (nonlocal_goto_handler_labels)
	return 1;
      /* Fall through.  */
    default:
      return can_throw_internal (insn);
    }
}

/* INSN is a copy from SRC to DEST, both registers, and SRC does not die
   in INSN.

   Search forward to see if SRC dies before either it or DEST is modified,
   but don't scan past the end of a basic block.  If so, we can replace SRC
   with DEST and let SRC die in INSN.

   This will reduce the number of registers live in that range and may enable
   DEST to be tied to SRC, thus often saving one register in addition to a
   register-register copy.  */

static int
optimize_reg_copy_1 (rtx insn, rtx dest, rtx src)
{
  rtx p, q;
  rtx note;
  rtx dest_death = 0;
  int sregno = REGNO (src);
  int dregno = REGNO (dest);

  /* We don't want to mess with hard regs if register classes are small.  */
  if (sregno == dregno
      || (SMALL_REGISTER_CLASSES
	  && (sregno < FIRST_PSEUDO_REGISTER
	      || dregno < FIRST_PSEUDO_REGISTER))
      /* We don't see all updates to SP if they are in an auto-inc memory
	 reference, so we must disallow this optimization on them.  */
      || sregno == STACK_POINTER_REGNUM || dregno == STACK_POINTER_REGNUM)
    return 0;

  for (p = NEXT_INSN (insn); p; p = NEXT_INSN (p))
    {
      /* ??? We can't scan past the end of a basic block without updating
	 the register lifetime info (REG_DEAD/basic_block_live_at_start).  */
      if (perhaps_ends_bb_p (p))
	break;