The S&P 500 has had a banner year, posting a 19% gain so far as excitement about artificial intelligence, a recovery from last year's sell-off, and an improving economy have lifted the broad market.

However, not every S&P 500 stock has been a winner. In fact, a number of stocks in the market-tracking index have fallen sharply this year. Let's look at the four worst performers to see if any are worth buying today.

A stock chart going down

Image source: Getty Images.

1. Advance Auto Parts, down 51.3%

Advance Auto Parts (AAP 0.58%) has been the worst performer by far on the S&P 500 this year.

While auto parts stocks O'Reilly Automotive and AutoZone have outperformed the market over the long term, Advance Auto Parts has significantly lagged behind its peers despite having a similar business model.

The stock plunged sharply following the company's most recent earnings report. 

^SPX Chart

^SPX data by YCharts

The auto-parts industry tends to be recession-proof, but while its peers were posting solid results, Advance said comparable store sales fell 0.4%, and the company slashed its full-year guidance and its dividend. It now expects earnings per share of $6.00 to $6.50, down from a previous range of $10.20 to $11.20. It also lowered its quarterly dividend from $1.50 to $0.25 per share, which seemed to be the primary reason for the sell-off.

Advance is also looking for a new CEO to replace Tom Greco, who is planning to retire. Any turnaround is likely to require a new leader, and that will take time. Given that delay and the pressure on the bottom line, the stock is best avoided.

2. KeyCorp, down 33.3%

Regional banks have struggled this year following the crisis that sank Silicon Valley Bank and Signature Bank, and KeyBank parent KeyCorp (KEY 0.62%) has been the worst performing of the regional bank stocks included in the S&P 500, down 33%.  

The stock fell sharply in March as those banks went under, and it's yet to recover those losses.

^SPX Chart

^SPX data by YCharts

Second-quarter results missed expectations but showed that the bank was on stable ground. The bank did forecast a slight decline in net interest income for the rest of the year as well.

Still, with interest rates remaining high and the economy starting to recover, the environment could be favorable for KeyCorp to make a comeback. Other signs show the bank is on the right track, including a $1 billion increase in deposits over the prior quarter and low net charge-offs at just 0.17% of total loans. Total loans also increased 11% from the quarter a year ago to $120.7 billion.

While KeyCorp is still facing some challenges, the stock also offers a 6.9% dividend yield, making it a solid bet for investors willing to ride out the volatility as the economy seems poised for a recovery.

3. Dollar General, down 33.1%

Dollar General (DG -0.41%) might be a surprising name to see on this list. After all, the retail stock tends to thrive in recessionary environments because of its reputation for low prices.

However, a combination of an elevated valuation coming into this year and a shift in consumer spending from goods to services seems to explain its troubles. The stock plunged following the company's most recent earnings report.

^SPX Chart

^SPX data by YCharts

In its fiscal first-quarter earnings report, comparable sales rose 1.6% and overall revenue was up 6.8%. Adjusted earnings per share fell from $2.41 to $2.34.

However, the main reason for the sell-off was a cut in EPS guidance resulting from a challenging macroeconomic environment. It now forecasts a full-year performance in a range of an 8% decline to flat growth, compared with a previous range of 4% to 6% growth.

While that guidance makes it clear the company is struggling in the current environment, its valuation looks much more reasonable after the sell-off at a price-to-earnings ratio of 15.5, and the company has long-term competitive advantages, including its unrivaled store footprint, low prices, and a multicategory product assortment. It's worth buying the dip on this one.

4. Enphase Energy, down 32.3%

Solar-energy company Enphase Energy (ENPH 3.80%) has been another big loser this year. Once again, the stock suffered a big setback following an earnings report.

^SPX Chart

^SPX data by YCharts

The stock fell back after it missed first-quarter revenue estimates and offered below-consensus guidance for the second quarter. Revenue in the quarter rose 64.5% to $726 million but fell 9% sequentially in the U.S. because of seasonality and macroeconomic conditions. Its second-quarter guidance calling for flat sequential revenue growth at $700 million to $750 million disappointed the market.

With revenue growth seemingly plateauing and the valuation elevated, investors may want to wait until stronger growth returns at Enphase, especially given the long-term underperformance in the solar industry.