With Shimano 8 and 9 speed systems you can interchange derailleurs as they use the same actuation or pull ratio (the ratio of length of cable pulled to lateral derailleur cage movement). The number of sprockets in the cassette and shifter must match obviously.
If you are experiencing poor shifting after a crash you should diagnose the cause before just replacing the derailleur. Take the rear wheel out of the bike and check the derailleur movement with the shifter and by manually manipulating it. If the B-pivot, parallelogram and cage pivot all move smoothly without lots of play, the cage isn't bent and the idler wheels turn freely the derailleur itself is probably fine.
A prime suspect for cause of bad shifting after a crash is a bent derailleur hanger. If you hold the rear of the bike up look down the line of the chain the derailleur cage should look parallel with the chainrings. Good bike repair shops have a special tool to straighten and align hangers.
Also check the cable run, make sure the housing is properly seated in the shifter body, frame stops and the derailleur, and the cable is clamped on the derailleur properly.