Companies most directly affected by trade issues could have a hit to earnings that is 10 percent to 40 percent greater than the hit to profits, they said. In a full-scale trade war, where the rift intensifies and tariffs are put on nearly all goods, S&P earnings could take a 14.6 percent hit.

Parker and other UBS analysts issued a comprehensive note this week on the effect of different trade scenarios on a wide range of companies and sectors.

If trade frictions with Europe resume and global auto tariffs are put in place, stock prices could see an 11 percent decline. But in a full-blown global trade war, where the U.S. and China are retaliating with higher and higher tariffs and other actions, the stock market could lose more than 20 percent, commodities prices could collapse and growth would slow in both countries, he said.

Keith Parker, head of U.S. equities strategy at UBS, said if the next round of U.S. tariffs on $200 billion of Chinese goods is put in place, earnings could take a hit of about 5 percent and the stock market could see a mid-single-digit decline.

The stock market has not priced in an escalation of trade tensions, which would slam some companies more than others, bite into earnings growth and force companies to raise prices and cut spending, according to UBS.

"I think the key takeaway is this could be very disruptive. The industries are sizable," said Parker. "In this solid growth and investment backdrop, we'd see companies pull back a bit."

Parker said he's still targeting 3,150 on the S&P 500 by year-end. "We're in talks with the EU, and some of the downside scenario is gone near term," he said. If 25 percent auto tariffs had been implemented at the same time as the next round of tariffs on Chinese goods, the impact would have been much greater. So far, China has said it would put tariffs on $60 billion in U.S. goods in response to the U.S. threat of tariffs on $200 billion.

Those would be on top of U.S. tariffs on steel and aluminum, which have brought retaliating tariffs on a range of U.S. products, including bourbon and soybeans. The U.S. and China have already implemented or expect to implement tariffs on another $50 billion in goods each.

UBS identified 34 companies that it sees as the most negatively impacted by tariffs. Those companies, in the firm's coverage universe, have trailed the S&P 500 by 4.5 percent since trade tensions began escalating in March.

A broader trade war would affect growth both in China and the U.S., which UBS economists now forecast at just 1.6 percent for the fourth quarter. That figure includes the next wave of tariffs on $200 billion in Chinese goods and is more than 1 percentage point lower than their prior forecast.

Since tariffs are aimed at specific products, the analysts say individual industries should react differently. For instance, electrical equipment and multi-industry and tech hardware firms could pass on 50 percent of the costs from tariffs directly to customers. But margin-sensitive general merchandise and apparel firms, and also semiconductor companies, would be more likely to pass on much less of the costs.

Within the retail sector, UBS said home improvement and auto parts retailers should have better pricing power than others and would be able to pass costs to consumers more easily. The strong niche brands that can raise prices, such as Nike and Lululemon, should be less affected than retailers such as Macy's, Kohl's and Gap, which sell private-label brands or lack the ability to raise prices.

"We don't believe the market is pricing in a potential trade war," and the market seems to assign a low probability, wrote analysts who follow softlines retailers. They also say investors should pay attention to where companies source their goods, as the more diversified firms will be able to shift supply chains to limit the damage from any trade war with China.

If the auto sector were caught up in a full-blown trade war, UBS analysts see costs rising by 9 percent, and when assuming all costs are passed to consumers, sales could fall by 12.2 percent, or 2.1 million units. "A trade escalation looks priced in for auto suppliers, and more than priced in for automakers," they noted.

The analysts said semiconductor companies would be hurt by a trade war. The most hard-hit would include Qualcomm and Micron, because they have the most direct revenue exposure to China. About 65 percent of Qualcomm's revenue is from China, and Micron's is just over 50 percent.

"The semiconductor trade imbalance in China is second only to oil," they wrote. The analysts said the companies in the sector they follow have revenue exposure of about 30 percent, but more than 50 percent of all semiconductor dollars are "ultimately consumed in China."

Semiconductor companies could open manufacturing facilities in China to sell directly within the country, avoiding the need to import.

Other companies may also consider moving production to make adjustments in their supply chains or look elsewhere for more non-Chinese goods.

In an escalating trade war situation, companies would cut costs. Capital spending could take a hit, with chemical firms, energy companies, freight carriers and companies in the electrical equipment and multi-industry sectors potentially cutting expenditures by up to 10 percent, the analysts estimated.

Here's how UBS analysts expect different sectors to respond in an environment of rising trade tensions, and their views on which stocks would be more or less affected by adverse trade actions.

Electrical equipment and multi-industry — The least affected would be those with a higher domestic exposure, lower debt and the ability to raise prices. Within the sector, there's higher risk for exposure to autos. Less impacted: Danaher and 3M. More impacted: ITT, Rockwell Automation and SPX Flow.

Machinery — Higher steel prices from tariffs have already hit this sector, and some hits to earnings are priced in. UBS recommended favoring domestically oriented companies in machinery, and to avoid stocks exposed to falling agricultural commodity prices. Less impacted: United Rentals. More impacted: Deere, ITW.

Autos — Stocks with U.S. production and cost advantages should do better than companies that rely on significant Chinese imports. Less impacted: Ford. More impacted: Aptiv or Visteon.

Freight transport — Companies with limited revenue exposure outside the U.S. should do better. There is not much expectation of a trade war priced in, but companies would likely pare capital spending and trim work forces in the event of one. Less impacted: Echo Global Logistics, Heartland Express and Werner Enterprises. More impacted: Canadian Pacific, Canadian National Railway and Expeditors International.

Semiconductors — Companies that have no non-U.S. alternatives and have performance-driven products should do better than those with significant Chinese revenue exposure. Less impacted: Nvidia and Intel. More impacted: Qualcomm, Micron and AMD.

Retailers, food chains — UBS does not see much evidence that a larger trade war is priced into this sector. Chains with pricing power should do better than those with significant imports from China. Home furnishings firms source most products from China, from 30 percent to 70 percent, but auto parts are 30 percent to 40 percent. Less impacted: Advance Auto Parts, O'Reilly Automotive and Tempur Sealy. More impacted: Bed Bath and Beyond, Best Buy and Pier 1 Imports.

Chemicals — Companies with less cyclical businesses, that are consumer focused and have less Chinese exposure should do better than companies more exposed to slowing global growth and pricing tied to crude oil. Less impacted: International Flavors and Fragrances, Ecolab and Mosaic. More impacted: Olin, LyondellBasell, and Methanex.

Metals and Mining — Companies with gold exposure as a hedge and high-grade steel makers that would benefit from reductions in Chinese steel capacity should do better than companies with exposure to copper, the U.S. auto sector and a slowdown in Chinese growth. Less impacted: Barrick, Vale. More impacted: AK Steel, Gerdau.

Oil and gas — Large-cap companies that are diversified and buyers of their stock should do better than the smaller-cap stocks that are highly levered to oil. Less impacted: Occidental, ConocoPhillips. More impacted: Denbury Resources, MEG Energy.