I'm going to assume that your comment is part of your question. Actually, you have it backwards. The volumetric work done by the surroundings on the gas is always $$W=-\int_{V_1}^{V_2}{P_{ext}dV}$$ irrespective of whether the process is reversible or irreversible, where $P_{ext}$ is the external force per unit area exerted by the surroundings on the gas at the interface between the system and surroundings at which the displacement is occurring. So, for compression W is positive if $V_1>V_2$ and negative if $V_1<V_2$.
For a reversible volume change, $P_{ext}$ can be taken as being equal to the pressure of the gas calculated from the equation of state, but for an irreversible volume change, since the equation of state does not apply to non-equilibrium states of a gas, the equation of state can't be used. In an irreversible process, there are (un-quantified)viscous stresses also present within the gas that contribute to the force per unit area exerted by the gas at its interface with its surroundings. Therefore, for an irreversible process, our only option for being able to calculate the work is to specify the external pressure $P_{ext}$ manually by imposing a known force per unit area (as a function of time) at the interface or somehow automatically controlling the external pressure.