SAN FRANCISCO (AP)  Advanced Micro Devices Inc. shrank its second-quarter loss on reviving sales of computers that use its chips and a wrenching years-long effort to shed costs.

A.M.D. would have made money were it not for a loss related to its investment in factories it spun off a year ago into a separate company, according to results released Thursday.

Two days earlier, A.M.D.’s rival, Intel, reported the highest revenue and profit margins in the company’s 42-year history. A.M.D.’s chips are inside 20 percent of the world’s personal computers and servers. Intel supplies nearly all the rest.

Intel cited bigger corporate spending on PCs and servers that use expensive chips  an encouraging sign for the semiconductor industry that shows technology budgets are being reinflated. A.M.D. said it notched record shipments of laptop chips in the latest period.