The Canadian subsidiary of General Motors Corp. is negotiating a possible sale of railway locomotives to Iran, a company spokesman confirmed today.

The administration of Prime Minister Pierre Elliott Trudeau, who will discuss economic matters with President Reagan in Washington Thursday, removed sanctions on trade with Iran in May 1981. They were imposed in concert with other western nations in response to the taking of U.S. hostages in Tehran in 1979.

Discussions of a possible sale of locomotives have been under way for about a week between the Iranian government-run railway company and salesmen from the Diesel Division, General Motors of Canada Ltd. of London, Ont., said spokesman Gordon Soutter.

He declined to say when a decision could be expected. The GM of Canada locomotives are valued at about $1 million each. Sales in recent years have included 143 to Egypt and 110 to Yugoslavia.

An official at the U.S. Embassy in Ottawa said he doubted American officials would object to the Canadian company's dealings with Iran, despite that nation's ongoing conflicts with the United States.

"There may be some public opinion about it," the official said, "but we don't have any problems with it."

There has been sporadic friction between Washington and Ottawa in recent years arising from sales by companies in Canada to Cuba and other nations covered by U.S. trade sanctions. The issue is complicated by the presence in Canada of thousands of subsidiaries of American corporations.

Canadians consider attempts by Washington to control or influence trading by businesses operating here to be an unacceptable infringement on Canada's sovereignty.

Asked if GM of Canada was worried about the implications of its trading with Iran, Soutter said, "It is well within the scope of what Canada is permitting and smiles upon."

Canadian sales to Iran fell to almost nothing during the period of the Iranian revolution and the U.S. hostage taking. Last year, exports from Canada to that country climbed sharply to about $150 million.