Occidental Petroleum Corp. and Diamond Shamrock Corp., two upstart oil companies that have become among the industry's largest through acquisitions, said yesterday they are considering merging with each other.

The companies said they were discussing a "possible business combination," and promised further information on the transaction after directors' meetings Monday, but analysts speculated that the companies would merge, with Occidental exchanging more than $2 billion worth of its stock for Diamond Shamrock's shares.

Diamond Shamrock stock, the most actively traded issue on the New York Stock Exchange yesterday with more than 3 million shares changing hands, rose $3 to $20.75. Occidental fell $2 to $24.75.

A merger of Los Angeles-based Occidental, the eighth-largest U.S. oil company, and Dallas-based Diamond Shamrock, ranked 18th, would create a $23-billion-a-year energy conglomerate, ranked seventh in the industry, behind Atlantic Richfield and ahead of Shell Oil, and 12th among U.S. industrial companies.

There was immediate speculation on Wall Street that the deal could pave the way for the retirement of Armand Hammer, Occidental's 86-year-old chairman, who might eventually be replaced by Diamond Shamrock Chairman William H. Bricker. Bricker has long sought the top spot at a major oil company.

But the feisty Hammer, whose recent talks with Soviet leader Konstantin Chernenko underlined his role as an international figure, has so far shown no sign of giving way for new blood at the top of Oxy. Last year, he forced out two possible heirs-apparent when he felt they threatened his power base, and he has removed other perceived threats to his reign in the past. Occidental's current president, Ray Irani, was formerly an executive at Diamond Shamrock, and apparently has played a key role in the merger negotiations.

"I think Hammer, under the right circumstances, in two or three years is ready to relinquish most of the role" of chief executive, said Bruce Lazier, an analyst at Prescott, Ball and Turben. "It offers Bricker, I think, a shot at being heir-apparent at Oxy."

The merger could greatly dilute Hammer's longtime iron-fisted control of Occidental by adding executives and board members from Diamond Shamrock, but Lazier said Hammer probably would require that his position be protected in any deal.

Over the past three decades, Hammer has built Occidental from virtually nothing into a major oil company through a series of timely acquisitions. Similarly, Diamond Shamrock has greatly increased in size in recent years by buying other companies, most recently its purchases in 1983 of Natomas Co., a large oil producer, and Sigmor Corp., a major independent refiner and marketer of gasoline.

Hammer may have hinted at his company's interest in Diamond Shamrock earlier this week in an interview with The Associated Press, when he said he no longer believed that the recent spate of oil-industry mergers had come to an end. He said in the interview that he expected more takeovers because oil reserves are limited and "it is cheaper to buy new reserves on Wall Street than to discover them yourself."

Similar thinking led to the gargantuan acquisitions of Getty Oil by Texaco Inc. and Gulf Corp. by Chevron Corp. last year, as well as a number of smaller mergers in the industry. Last week, Mesa Petroleum Co. Chairman T. Boone Pickens Jr. dropped his efforts to acquire Phillips Petroleum Co.

Lazier said one reason for the Occidental-Diamond Shamrock merger might be to fend off any takeover interest in either company from others in the oil industry.

Analysts said Occidental may be interested in Diamond Shamrock for its oil-producing properties, notably the Indonesian operations it obtained by buying Natomas, and in its coal and specialty chemical divisions, which would complement Occidental's considerable holdings in those areas.

They suggested that Occidental might put Diamond Shamrock's gasoline retailing operations up for sale shortly after a takeover; Occidental has never been much interested in selling gasoline, and sold Cities Service's marketing operations after it bought that company two years ago.

In a diversification from the oil business, Occidental also owns IBP Inc., a major beef and pork processor -- although Hammer is reportedly seeking to sell the unit because he perceives a threat to his leadership from one of its top executives.