Trying to time the market is impossible, and it's what makes diversification so important in a portfolio. Many stocks are down this year primarily because of sky-high inflation and a potential recession. Yet those two factors have contributed to the rise of consumer-staples stocks like General Mills (GIS -0.37%). They have also contributed to a sell-off in quality durable-goods stocks like Whirlpool (WHR -0.54%).

Which sector should long-term investors choose? Diversifying between the two could increase your chances of being right. In addition, both pay reliable cash dividends, which can be reinvested to help compound long-term returns.

 Let's take a closer look at these two dividend stocks that offer safety and diversification.

Seven glass jars filled with pennies.

Image source: Getty Images.

1. General Mills

General Mills produces an extensive list of foods and snacks, some of which are likely to be in your pantry right now. Over the decades, General Mills has supplemented its legendary Betty Crocker cake mixes, Cheerios, Chex, and Bisquick brands with more recent additions like Bugles, Chex Mix, and Gardetto's. The company's breakfast cereals and snacks are go-tos for millions of customers. In past tough times, the familiar and inexpensive dietary staples were one of the last things shoppers gave up when tightening their budgets.

The popularity of General Mill's brands has helped the stock attain the reputation of being recession-proof. This time around is no different. As an increasing fear of a recession causes some investors to sour on stocks, the S&P 500 index has slipped 17% in 2022 and has been down as much as 23.5% from all-time highs set early in the year. Meanwhile, General Mills has significantly outperformed, rising 8.5% this year.

If record-high inflation persists and/or the U.S. does enter a recession this year or next, the stock will likely continue to outperform. If not, investors aren't likely to see it greatly falter as the stock pays a healthy dividend that helps keep it from falling too far. The dividend currently yields 2.8%, which is above average in comparison to the S&P 500 (at 1.6%) but down from its five-year average of 3.6% largely because the stock price has done so well this year.

2. Whirlpool

Next to the General Mills products in your pantry, you might have a refrigerator or a dishwasher you bought from Whirlpool. The company also sells popular washer and dryer brands, Maytag and Amana. Unlike breakfast cereal, these are high-priced appliances that may top the list of items to pass on when budgets tighten during a slowdown.

This scenario is a likely cause for Whirlpool's underperformance this year -- the stock is down about 29%. However, one underrated characteristic of Whirlpool's business is its replacement segment. Putting off buying a pricey appliance is an easy choice if you don't need to replace your dishwasher, for example, during a recession. But if it's broken beyond repair, that's a different story. Consumers are always going to find a need for appliances eventually.

Then there's the fact that, despite the worries about recession, durable goods shipments and new orders have continued to grow at a very steady pace over the past year (see chart below). They point to a pent-up demand that hasn't yet eased.

US Durable Goods Shipments Chart

US Durable Goods Shipments data by YCharts

Whirlpool's more steady replacement business and consumers' apparent continued appetite for durable goods should give investors confidence that this stock will eventually recover. In the meantime, its 3.8% dividend yield will continue to be paid, even during the worst times.

Best of both worlds

If you're unsure which sector will outperform the index for the rest of the year, don't worry. Short-term market timing has proven futile over and over again. Diversification, on the other hand, is a tried-and-true investment tool. These two companies have different characteristics that make their stock perform differently in the short term. Investing the two together can help smooth some of the bumps in your overall portfolio.

Both are quality companies that are leaders in their industries and should do well in the long run. Investors can do well by holding a portfolio of 25 to 30 stocks of quality companies with diverse characteristics for at least five years. In addition, these two stocks pay a reliable dividend that can provide capital to reinvest and compound long-term returns.