The S&P 500 (SNPINDEX:^GSPC) had a reasonably good month in April, with the index rising 0.6% and achieving its best monthly close ever. But several stocks blew the lights out, with impressive gains that far exceeded what the broader market gave investors. Let's take a closer look at Allergan (UNKNOWN:AGN.DL) and Pepco Holdings (UNKNOWN:POM.DL) to find out why they topped the list with gains of more than 30%, and then we'll also look at some other hot areas that performed well during the month.

Allergan gained more than 33% after the maker of Botox got a $45 billion buyout offer from Valeant Pharmaceuticals. The deal includes about one-third of the offering price in cash and the rest in shares, but Allergan actually traded well above the value of the bid as Allergan shareholders speculated that the company would hold out for a better offer. Indeed, Allergan proceeded to adopt a poison-pill defense to prevent Bill Ackman's Pershing Square Management from increasing his already substantial stake in the company. Investors could get further gains if Allergan receives a sweetened deal, but Allergan also runs the risk of a big share-price decline if the transaction ends up falling through.

Meanwhile, utility Pepco Holdings jumped 31% after it agreed to a friendly takeover from Exelon. The all-cash deal values the mid-Atlantic utility company at $6.8 billion, and Pepco argued that customers should like the merger because of the vast capital resources that the combined company can bring toward improving infrastructure as well as potential cost reductions that could help take upward pressure off utility rates. Pepco shareholders will need to approve the deal, but with both boards of directors supporting it, it's likely that the merger will happen by the middle of next year.

Source: Letartean, Wikimedia Commons.

Finally, the energy industry also performed well in April, with three companies in the oil and gas and coal industries posting gains of more than 15%. Coal companies have struggled under the weight of strong competition from natural gas, but the recent rise in natural gas prices has finally helped coal companies see the potential for higher demand from electricity-generating utilities and other major customers. Meanwhile, merger-and-acquisition activity throughout the stock market has captured the attention of energy investors, especially as major oil companies seek to flesh out their asset portfolios in order to keep production levels growing.

With Pepco Holdings and Allergan, investors shouldn't expect to see further gains, even given an unpredictable M&A environment that can sometimes lead to surprising twists like rival bids. For energy stocks generally, though, low valuations make the sector an interesting one for investors looking for ways to invest prudently even with the S&P 500 near record highs.

Dan Caplinger has no position in any stocks mentioned. The Motley Fool recommends Exelon and Valeant Pharmaceuticals and owns shares of Valeant Pharmaceuticals. Try any of our Foolish newsletter services free for 30 days. We Fools don't all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.