Not every stock is sinking these days. Some have managed to rise despite a dismal stock market environment.

Even better, some of these gravity-defying stocks remain attractively valued. Here are three cheap stocks to buy that are crushing the market.

1. Devon Energy

Just a few weeks ago, shares of Devon Energy (DVN 0.58%) were skyrocketing more than 75% year to date. Although a lot of those gains have since evaporated, the oil stock is still up around 30% so far in 2022. And that follows a gain of nearly 179% last year.

Rising oil prices continue to serve as a massive tailwind for Devon. Even if prices decline somewhat, the company should still be in great shape

In addition to its sizzling stock performance, Devon offers one of the juiciest dividends you'll find. It features a fixed component and a variable component funded by excess free cash flow. Devon's dividend yield currently stands at nearly 8.8%.

You might be surprised that the stock still looks cheap after delivering such impressive gains over the past 18 months. Devon's shares trade at only 8.3 times expected earnings.  

2. Vertex Pharmaceuticals

Most biotech stocks have taken a drubbing since last year. Vertex Pharmaceuticals (VRTX 1.43%) is a clear exception. Its shares have jumped more than 20% year to date and could pick up even more momentum.

There's been plenty of good news for Vertex in 2022. Sales for its cystic fibrosis (CF) franchise continue to grow robustly. The company has scored additional regulatory wins and reimbursement deals across the world for its top-selling CF drug, Trikafta/Kaftrio. Vertex has also announced positive progress with its pipeline. 

Even better news could be on the way. Vertex and its partner, CRISPR Therapeutics, hope to file for regulatory approvals of exa-cel (also known as CTX001) in treating sickle cell disease and beta-thalassemia later this year. The CRISPR gene-editing therapy holds the potential to become a blockbuster if approved. 

Vertex stock might not look all that cheap based on its forward earnings multiple of 17.7. But it's important to factor in the biotech's growth prospects from its CF drugs, exa-cel, and other late-stage programs that could be big winners. Using the price/earnings-to-growth (PEG) ratio incorporates that growth potential. Vertex's PEG ratio stands at a super-low 0.37, qualifying this high-flying biotech stock as a bargain right now.

3. Markel

Sure, Markel (MKL 1.01%) hasn't delivered the strong gains in 2022 that Devon and Vertex have. However, the stock is still handily beating all of the major market indexes so far this year with an increase of close to 5%.

Markel was one of only eight new stocks that Warren Buffett's Berkshire Hathaway bought in the first quarter. And it's arguably the best of the bunch.

Like Berkshire, Markel focuses primarily on the insurance business (in this case, specialty insurance). Markel also, like Berkshire, invests in other publicly traded companies. Its largest position is none other than Berkshire. Unsurprisingly, Markel is sometimes referred to as a "baby Berkshire" because of these similarities.

Markel also shares something in common with Vertex Pharmaceuticals. Its forward earnings multiple of 17.2 is in the same ballpark as that of Vertex. But like the big biotech, Markel's valuation looks attractive when its growth prospects are factored in. Its PEG ratio currently stands at 0.89.