BankAmerica Corp. reported yesterday that its troubles returned in the second quarter, when it lost $640 million because of a huge addition to its loan-loss reserves.

The loss, the second-largest to be reported by a bank for a three-month period since the Great Depression, surprised analysts. They said it showed that the company, the parent of Bank of America, is performing worse than it had said it would as recently as a month ago. However, because BankAmerica has a large consumer deposit base, analysts said they didn't expect it to deteriorate to the point that it requires federal assistance, as Continental Illinois Corp. did two years ago.

Continental suffered the largest quarterly loss of any U.S. bank since the 1930s in the second quarter of 1984, when it fell $1.16 billion into the red. It was later rescued by the Federal Deposit Insurance Corp.

BankAmerica said it increased its reserves for future loan losses by $600 million in the second quarter. The addition, which is taken directly from profits, raised the loan-loss reserves to $2.2 billion, or 2.67 percent of total loans outstanding. That level is the highest of any major U.S. bank, the company said.

Samuel H. Armacost, BankAmerica's chairman, who has had a precarious hold on his job because of the bank's problems, said loan-loss reserves were increased because of the impact of lower oil prices on regional economies where the bank has many loans, the excess supply of commercial real estate space, and heightened financial stress among some Third World borrowers.

For the first six months, BankAmerica's loss totaled $577 million, compared with $224 million for the first half of 1985.

The company earned $63 million in the first quarter after losing $337 million last year, and had said it expected to lose $1.2 billion for all of 1986. But yesterday, the bank said that estimate would have to be raised in light of the second-quarter performance, the Reuter news service reported.

"It's a major hit," said Lawrence Cohn of Merrill Lynch. The increase in loan-loss reserves shows "they recognize there are additional loan charge-offs yet to be taken" in the next two quarters. "They're getting prepared for that. The charge-offs in the third and fourth quarter will be high.

"In the last two years they made an enormous amount of progress correcting the problems, but the loans were already on the books," Cohn said.

Cohn said he doesn't expect the bank's profits to turn around before another six to 18 months. "Things will get better, but slowly," he said.

"The return to profitability is a very difficult question," John S. Poelker, executive vice president and chief financial officer, said in a telephone interview. "We're optimistic in the second half of this year the fundamental improvements we're making . . . are going to help us move toward that goal" of profitability. "We can't be put in the position of forecasting earnings because we're in a very volatile environment."

The two major rating agencies, Moody's Investors Service and Standard and Poor's Corp., responded to the announcement by downgrading BankAmerica's debt.