U.S. stocks rose, with benchmark indexes extending records, as small-cap shares rallied, and Family Dollar Stores advanced with Analog Devices amid deal activity.

Family Dollar jumped 13 percent as a filing showed Carl Icahn has amassed a 9.4 percent stake. Analog Devices jumped 5 percent after agreeing to buy a chipmaker for about $2 billion. Idenix Pharmaceuticals Inc. more than tripled after Merck & Co. agreed to buy the drugmaker for $3.9 billion. Apple Inc. traded at $93.70, reflecting a seven-for-one stock split.

The Standard & Poor’s 500 Index added 0.1 percent to 1,951.27, capping its seventh record close in the past eight sessions. The Dow Jones industrial average gained 18.82 points, or 0.1 percent, to a record 16,943.10. The Russell 2000 Index of small companies climbed 0.9 percent for a fourth day of gains. About 5.3 billion shares changed hands on U.S. exchanges, 15 percent below the three-month average.

“There’s a fair amount of skepticism over if we are at peak valuations,” said Michael Arone, the Boston-based chief investment strategist at State Street Global Advisors’ U.S. Intermediary Business. State Street Corp. oversees $2.4 trillion in assets. “My view is the Goldilocks economy is back – not too cold, not too hot, but just right. What we’re starting to see is companies starting to do capital expenditures and M&A to invest in their businesses.”

Dollar General Corp. rallied 7.4 percent to $62.25. Jefferies Group LLC raised its rating on the stock to buy from hold after Icahn’s purchase of Family Dollar shares. The move may lead to a merger with Dollar General, Jefferies said. Dollar Tree Inc. gained 0.7 percent to $55.50, a seventh straight gain that is the longest streak since November.

Gilead Science Inc., the developer of Sovaldi, a competing hepatitis C treatment, fell 4.1 percent to $79.01.

Apple shares climbed 1.6 percent to $93.70. The shares closed Friday at $645.57. Apple said on April 23 it was doing the split so shares would be available to a wider pool of investors.