The LM317 has an Absolute Maximum input-output differential of 40V so, for good reliability, you should have a maximum input voltage of a few volts less than 40V. You especially need to watch the voltage out of a diode capacitor rectifier DC source whose voltage will reach near the peak AC voltage under no load.
Also the minimum in-out differential is about 3V, so the maximum regulated output from the L317 is the input voltage minus 3V.
Thus realistically you shouldn't expect to get more than about 35V out of the LM317.