If the piston is massless, then, by Newton's 3rd law, the force per unit area exerted by the gas on the inside face of the piston must be equal and opposite to the force per unit area exerted by the surroundings on the outside face of the piston, irrespective of whether the process is irreversible. Therefore, the work will be the same, but of opposite sign.
If the piston has mass, the force per unit area exerted by the gas on the inside face of the piston minus the force per unit area exerted by the surroundings on the outside face of the piston will equal the mass times acceleration of the piston. But, if the system eventually equilibrates with its surroundings (as a result of viscous stresses within the gas causing the dissipation of the kinetic energy of the piston), the net work done by the gas will, again be equal in magnitude and opposite in sign to the work done by the surroundings. This is true even if the piston contact with the cylinder is frictionless.
So, what is going on? Well, first of all, even for an ideal gas, the ideal gas law only applies when the gas is at thermodynamic equilibrium. In a reversible process, the gas passes through a continuous sequence of thermodynamic equilibrium states, so the ideal gas law always applies. But, in an irreversible process, the ideal gas is not at thermodynamic equilibrium, so the ideal gas law does not apply.
Then what does apply in an irreversible process? Well, gases (even ideal gases) are viscous fluids in which the state of stress is described by the equations for a Newtonian fluid. The Newtonian fluid equation predicts that the normal compressive stress (normal force per unit area) at the piston face is given, not by the ideal gas law, but by: $$\sigma=\frac{RT}{v}-2\mu\frac{\partial V}{\partial z}$$where v is the specific molar volume of the gas evaluated at the inside piston face, T is the temperature of the gas at the piston face, $\mu$ is the gas viscosity, V is the velocity of the gas (which varies with spatial position within the gas), and z is axial position along the cylinder. The first term on the right hand side of this equation is the pressure predicted by the ideal gas law (with all the parameters evaluated locally and the inside piston face), and the second term is the contribution of viscous stresses to the overall compressive stress at the piston face. Note that, for a reversible (quasi static, very slow deformation), the second term is negligible. Furthermore, for a reversible process, the specific volume, temperature, and pressure are uniform within the cylinder.
The net result of all this is that, for an irreversible process, the force per unit area that the gas exerts on the inside piston face is not determined solely by the volume of the gas but also by the rate of change of volume with time. This is the reason that the ideal gas law does not describe the force per unit area of the gas on the piston in an irreversible process. However, as indicated above, in the end, if the final state of the gas is again one of thermodynamic equilibrium, the work done by the gas on the piston will be equal in magnitude and opposite in sign to the work done by the surroundings on the piston.