The Nasdaq composite rose 21.56 points, or 0.7 percent, to 3,213.59.
"More deals out there do create a good sentiment," said Kevin Divney, chief investment officer at Beaconcrest Capital Management in Boston. "CEOs now are looking further out, and that's been the issue the past four years. If we can extend horizons, it makes for better strategic decisions."
Almost $40 billion in deals was announced in the United States on Thursday, bringing the total this month to more than $140 billion, according to data compiled by Bloomberg. That already surpassed the total of $99.6 billion during the first two months of 2012.
German investor confidence jumped more than economists forecast in February to the highest in almost three years, data showed Tuesday, adding to signs that Europe's largest economy is rebounding from its slump.
Nine out of 10 groups in the S&P 500 advanced, with consumer staples and energy shares climbing at least 1 percent.
Best Buy gained 2.7 percent, to $17.33, after Alan Rifkin, an analyst at Barclays P.L.C., raised the retailer of electronic goods to overweight, the equivalent of buy, from equal weight.
"We believe Best Buy is taking the necessary steps to improve operations by cutting costs out and driving efficiencies," Rifkin wrote in a report. "We are confident that management will work to defend share."
General Mills Inc. added 1.9 percent, closing at $45.43. The maker of Cheerios said profit would rise at a high single-digit percentage rate in fiscal 2014 and reiterated its earnings forecast for this year. Analysts project an increase of 8 percent to $2.90 per share, according to an average of estimates compiled by Bloomberg.
The National Association of Home Builders/Wells Fargo builder confidence index fell to 46 from January's 47, a report from the group showed. PulteGroup Inc. tumbled 1.8 percent to $19.95, and D.R. Horton Inc. lost 1.6 percent to $23.29.
Humana Inc. tumbled 6.4 percent to $73.01 for the biggest drop in the S&P 500. The second-biggest private Medicare insurer said the U.S. government's preliminary Medicare Advantage payment rates were less than the company anticipated.
The proposed rates also sent shares down. UnitedHealth Group Inc., the largest U.S. health-insurance provider, fell 1.2 percent to $56.66. Cigna Corp. lost 1.1 percent to $60.43.
Among casino companies, Wynn Resorts Ltd. dropped 2.1 percent, to $120.39, after CLSA Ltd. downgraded Wynn Macau, billionaire Steve Wynn's Las Vegas-based company, to outperform from buy. Wynn is among six applicants for Philadelphia's second casino license.
Las Vegas Sands Corp., which operates the Sands Bethlehem Casino, tumbled 3.1 percent to $51.25.