Stocks end broadly higher, breaking a 3-week losing streak