Top U.S. investors such as Berkshire Hathaway and Paulson & Co. slashed some energy investments in the second quarter amid strong gains in crude and natural gas prices.

Meanwhile, the firms also appearing optimistic by maintaining or placing new bets on the sector, regulatory filings showed on Aug. 12 and Aug. 15.

Warren Buffett's conglomerate Berkshire Hathaway cut its stake in oil E&P, refining and marketing company Suncor Energy Inc. (NYSE: SU) by 7.7 million shares to 22.3 million shares over the quarter, filings with the Securities and Exchange Commission (SEC) filing showed. The company's stock price was little changed at the end of the quarter.

Buffett's firm maintained its stake in pipeline company Kinder Morgan Inc. (NYSE: KMI) of 26.5 million shares, however, amid a nearly 5% gain in the company's stock price.

Berkshire also increased its stake in U.S. refining company Phillips 66 (NYSE: PSX) by 3.2 million shares to 78.8 million shares, despite a loss of 8.4% in the company's share price.

U.S. crude prices rose 26% over the quarter to $48.33 a barrel after topping $51 a barrel. Prices rallied after major producers, including Saudi Arabia and Russia, began talking of an output freeze to ease a supply glut. Although that cooperation never came about, crude prices were later supported by unexpected production outages in Canada, Nigeria and Libya.

John Paulson's hedge fund firm Paulson & Co. sold its entire stake of 3.2 million shares in E&P Whiting Petroleum Corp. (NYSE: WLL) in the April-June quarter.

That liquidation came amid a 16% run-up in the company's stock price over the quarter.

The firm trimmed its bets on E&P companies Cobalt International Energy Inc. (NYSE: CIE) and Oasis Petroleum Inc. (NYSE: OAS), but still kept the stakes sizable at 39.1 million shares and 5.3 million shares, respectively.

The firm largely held on to the Cobalt bet despite a 55% drop over the quarter, while Oasis gained more than 28%.

These fund SEC disclosures are backward-looking and come out 45 days after the end of each quarter. Still, the filings offer a glimpse into what hedge fund managers saw as investment opportunities.

While Paulson sold, Daniel Loeb's Third Point hedge fund took a new stake in Whiting Petroleum of 8.2 million shares. Barry Rosenstein's Jana Partners also showed a bullish tilt overall and jumped into Marathon Petroleum Corp. (NYSE: MRO) with a stake of 2.7 million shares.

Leon Cooperman's Omega Advisors took modest positions in E&P companies Antero Resources Corp. (NYSE: AR), Consol Energy Inc. (NYSE: CNX), and Pioneer Natural Resources Co. (NSYE: PXD). The hedge fund cut a stake in Targa Resources Corp. (NYSE: TRGP) by 1.6 million shares, however, to 1.1 million shares even as the natural gas pipeline company's stock price rose more than 40%.

While some funds showed optimism, David Tepper's Appaloosa Management cut stakes in natural gas MLPs Williams Partners LP (NYSE: WPZ) and Energy Transfer Partners LP (NYSE: ETP), along with Kinder Morgan. It exited stakes in E&P companies Southwestern Energy Co. (NYSE: SWN), Range Resources Corp. (NYSE: RRC) and Cabot Oil and Gas Corp. (NYSE: COG) as the companies shares rose about 56%, 33% and 13%, respectively.

David Einhorn's Greenlight Capital also appeared bearish and cut his firm's bet on Consol Energy by 7.6 million shares to 22 million shares. It also exited an 887,428 share bet on oilfield services company Oil States International (NYSE: OIS).

Greenlight also soured on renewable energy and sold its entire stake in SunEdison Inc. of about 21 million shares.