US stocks gained after a volatile session as dip buyers emerged after a cooler-than-forecast February inflation report.