When President Valery Giscard d'Estaing reached Bahrain during his recent tour of the Persian Gulf, his diplomats got the American flag hauled down at the U.S. ambassador's residence so that the French leader would not have to be photographed giving a speech with Old Glory waving just behind him.

U.S. Ambassador Robert Pelletreau was repaid for his understanding attitude by being the only American invited by his next-door neighbor, the French ambassador, to the garden party where Giscard was to address the tiny French community.

French gratitude did not go so far as to spare the U.S. ambassador from having to hear the kind of rhetoric against the presence of the superpowers in the gulf with which Giscard peppered his statements throughout his tour.

Giscard's performance seemed deliberately designed to recall the tours by his predecessor, Gen. Charles de Gaulle, who relished attacking "the two hegemonies" of American and the Soviet Union but always managed to convey the impression that he had a nostalgic attachment to old Russia. Giscard's suggestion that Western Europe, especially France, is prepared to replace the United States as the protector of the emirates of the gulf seemed more directed against Washington than against Moscow, despite the Soviet military expansionism in nearby Afghanistan.

Giscard, originally elected in 1974 as a man would restore close ties with France's more recent traditional allies such as the United States, has clearly entered a new phrase in his conversion to neo-Gaullism.

At first, Giscard seemed to be following a quiet, pragmatic brand of Gaullism that pursued the France first policies of De Gaulle but got far more results by avoiding unnecessary anti-American rhetoric that might only arouse Washington to countermeasures. This approach won Giscard arms contracts, guaranteed oil supplies and a much more effective version of the Paris-Bonn axis than De Gaulle's often ambivalent chancellor Konrad Adenauer.

More recently, however, Giscard and his entourage have been displaying the kind of unabashed anti-Americanism that used to prompt Giscardist rages against De Gaulle and his followers. Giscard does not go quite so far as statements like De Gaulle's denouncing Britian as America's Trojan Horse in Europe. But there are others who do the job for Giscard. His associates suggest that letting Britain into the Europe Economic Community was a mistake.

The most public of Giscard's point men in his close friends and former interior minister, Michel Poniatowski, who has staked out the role of a Giscardist Andrew Young. The difference is that the French president has not yet disavowed any of Poniatowski's outbursts, including the recent interview with a West German magazine calling President Carter "an imbecile" who acts like "a political Baptist."

In response to the accusation that he is a loose cannon on the French political deck, Poniatowski told another interviewer, "I only break the crockery that is pointed out to me for breaking."

Knowing just how much Giscard and Poniatowski really talk is widely regarded as the key to the president's current tactics. Even close Giscard aides say privately that they do not dare guess how much contact there is after working hours. Questioned about it, a Poniatowski lieutenant said, "That depends on the frequency of the hunts." Laughter to that response was greeted by the reminder that Giscard is a passionate hunter.

So, the snub Poniatowski got in Washington this week with the cancellation of his meetings with national security adviser Zbigniew Brzezinski and Energy Secretary Charles Duncan was widely viewed in Paris as an American warning to Giscard not to go too far.

The French president seems unlikely to listen too closely to the Americans during what amounts to an election year in France, as French politicians jockey for the presidential election in the spring of 1981.

Poniatowski fits into Giscard's stratery in other ways. He is understood to be the president's liaison man with his "objective" allies, the Communists. tPoniatowski meets frequently with Jean-Baptiste Doumeng, "the communist millionaire." Doumeng heads the party's huge agri-business operations, often in cooperation with the Rothschild banking interests, and is considered to be one of the half-dozen real powers in the party.

Giscard and the Communists have a mutual interest in seeing to it that Socialist leader Francois Mitterrand cannot replace Giscard in 1981. When he had Communist backing, Mitterrand came within about 200,000 votes out of 26 million of defeating Giscard in 1974.

Now that Giscard's image has been tarnished by allegations that he and relatives accepted diamonds from former Central African emperor Bokassa and Communist leader George Marchais' image has been tarnished by published reports of strong evidence that he was a volunteer in the Nazi war effort, Mitterrand's chances are beginning to look somewhat better.

The flirtation between the Socialists and the regular Gaullists of Jacques Chirac has led many analysts in France to rethink the country's traditional political arithmetic. The Guallist-Giscardist combination has spelled a majority in a country that was not prepared for the alternative of the Communist Party in government, even as a junior partner.

This French political new math comes in an economic and social context that is growing unfavorable for the government. Unemployment hovers around 1.5 million, inflation is approaching American levels, university unrest is reappearing after a decade of relative quiet, transportation and electrical workers' strikes are in the works as winter ends, and the autonomist movements in Corsica and Brittany seem to be gaining serious momentum.

Prime Minister Raymond Barre, who has served Giscard as a lightning rod for much of the discontent because he proudly claims credit for government economic policies, is now increasingly perceived as a serious liability to the president.

Barre's own Cabinet ministers do little to hide their dismay over his recent reply to young communist hecklers that the unemployed could find work by going out and starting their own businesses.

The newspaper Le Monde editorialized that while it is now known that Marie Antoinette wound up paying with her head for saying, "Let them eat cake" it is already known that Barre has lost his head.

The conventional political wisdom in Paris, however, is that it is probably already too late for Giscard to change prime ministers before the election.

"Obviously," said one political commentator, "Giscard seems to be trying to get out of this domestic dead end with a foreign policy that variously reassures or captivates the French people by its prudence, by its independence or simply by the splash it makes."

It is a tactic that Giscard apparently intends to continue. His foreign travel calendar is filling up with visits that are rich in symbolism. It already includes Finland, the country that exemplifies how a small nation stays independent on the doorstep of the Soviet Union; China, whose hostility to the Soviets is outweighed here by the way its ancient culture captures the French imagination; and Iraq, whose combination of oil, political extremism and economic pragmatism has long made it ideal terrain for the Gaullist approach.

Gaullist leader Chirac, whose thumder is being stolen by Giscard, seems too restive with his self-imposed image of responsible statemanship while awaiting better political days.

"If people really want Gaullism," he said, "it's far better to have it done by Gaullists who know how than to have it done by centrists."

Increasingly, however, there are serious analysts who are asking whether Giscrd has not been forced into a Gaullist foreign policy because the political logic of France's domestic and world situations makes it the only foreign policy that really serves French interests.