US stocks notched solid gains Wednesday, recouping some of the market’s losses from a day earlier.
Technology and health care companies drove much of the rebound, outweighing losses in safe-play stocks like utilities and real estate investment trusts. Small-company stocks fared better than the rest of the market.
Macy’s led a rally among retailers after reporting surprisingly strong results, adding to the strong wave of corporate earnings in recent weeks.
‘‘Earnings growth has shown through and that’s been primarily based on strong fundamental growth from U.S. companies,’’ said Jamie Lavin, global investment specialist at J.P. Morgan Private Bank. ‘‘And when equity markets are able to look through to that and we don’t have any major geopolitical headlines, we tend to have stronger days in the market.’’
The S&P 500 index rose 0.4 percent, to 2,722.46. The Dow Jones industrial average gained 0.3 percent, to 24,768.93. The increase nudged the 30-company average to a small gain for the year.
The Nasdaq added 0.6 percent, to 7,398.30. The Russell 2000 index of smaller-company stocks picked up 1 percent, to 1,616.37, topping its last all-time high in January.
The stock indexes wavered little from their upward trajectory as investors appeared to shake off concerns about the prior day’s spike in bond yields. The market also failed to react much to a Commerce Department report early Wednesday that showed residential construction fell 3.7 percent in April following a steep drop in apartment construction.
‘‘The market is taking the weaker number with a grain of salt, remembering that colder weather could be a factor,’’ Lavin said. ‘‘Year-over-year housing permits are still up.’’
Technology and health care companies bounced back Wednesday after taking some of the worst losses a day earlier. Western Digital rose 4.9 percent, while Cerner added 2.9 percent.
Investors continued to sift through the latest batch of corporate report cards from big-name retailers, many of which are issuing quarterly results this week.
Macy’s latest results far exceeded analysts’ expectations. The department store operator noted that its Bloomingdale’s and Bluemercury divisions as well as its flagship store brand all did well. The company’s shares led all stocks in the S&P 500, vaulting 10.8 percent higher.
‘‘Seeing encouraging earnings and guidance from Macy’s, on top of as-expected growth in retail sales, it gives investors additional reason to be optimistic,’’ said Sam Stovall, chief investment strategist at CFRA Equity Research.
Office Depot climbed 5.1 percent after it maintained its forecasts for the year. Nordstrom added 2.4 percent, while L Brands gained 2.6 percent. Target shares picked up 2.9 percent.
Investors will get to pore over more results from retailers Thursday, including from Walmart, J.C. Penney, and Nordstrom.
‘‘Retail is important because it’s a reflection of consumer sentiment and you have many people who are employed by the brick-and-mortar retailers,’’ Stovall said.
Abaxis was among the big gainers Wednesday. The veterinary diagnostics products company vaulted 16.2 percent after it agreed to be acquired by Zoetis.
Traders bid up shares in Teva Pharmaceutical Industries after Warren Buffett’s company, Berkshire Hathaway, more than doubled the size of its investment in the Israeli drug maker. Teva added 2.9 percent. Phillips 66 slipped 0.1 percent after Berkshire sold about half of its investment in the oil and gas company.
Bond prices fell. The yield on the 10-year Treasury rose to 3.10 percent from 3.07 percent late Tuesday, when the yield climbed to its highest level in nearly seven years.
The pickup in bond yields weighed on utilities and other high-dividend paying stocks, adding to their losses from a day earlier. Sempra Energy fell 1.8 percent.
Benchmark US crude oil recovered from an early slide, adding 18 cents to settle at $71.49 a barrel in New York. Brent crude rose 85 cents to $79.28 in London.