The direct energy gaps, Eg, and the indirect gaps at the X point, E(X), of GaAs and AlxGa1−xAs alloys are essentially linear functions of hydrostatic pressure, P. Recent photoluminescence measurements of Tozer et al. for InP under high pressures, however, found that Eg(P) is not quite linear, but bends down slightly at high pressures. Using the first-principles pseudofunction method, we have calculated Eg and E(X) as functions of pressure, as well as the zero-temperature equation of state P(V). Our calculated gap curve for InP, Eg(P), bends down slightly, as found in photoluminescence studies. The slope dEg/dP is 8.8 meV/kbar for small pressures P, and is in good agreement with the experimental value, 8.32 meV/kbar. The observed nonlinearity in the dependence of Eg on pressure for InP is attributed to a large derivative of the bulk modulus with respect to pressure. The calculated bond length, bulk modulus, and critical pressure for a phase transition from the zinc blende to a rocksalt structure, and the unit cell volume change at this phase transition are all in good agreement with the data.