Samsung Electronics Co. has surpassed Apple as the world’s biggest buyer of semiconductors last year because of demand for its smartphones and tablet computers, according to research firm Gartner.

Lenovo, which operates its executive headquarters in Morrisville and rose last year to the N0. 2 spot in global PC sales while also ramping up tablet and smartphone products, rose one spot to No. 6.

Cisco improved to the ninth spot from 11th a year ago. Cisco operates its second largest corporate campus in RTP.

The entire semiconductor market shrank, however, by 3 percent, Gartner reported. Gartner said sagging PC sales drove down chip demand.

“While the growth of new mobile computing devices, notably smartphones and media tablets, has not fully compensated for the drop in the semiconductor demand from the PC market, the data center and communications infrastructure market will keep driving semiconductor demand,” Gartner analyst Masatsune Yamaji said. “The limited computing and storage resources of new mobile computing devices will be compensated for by cloud computing services with light application software.”

Samsung’s chip purchases surged 29 percent to $23.9 billion in 2012, the Stamford, Gartner reported Wednesday.

Apple’s (Nasdaq: AAPL) semiconductor spending rose 14 percent to $21.4 billion, it said.

The Korean company is buying more chips as its wider range of mobile devices helps it outsell Apple in markets from the U.S. to China.

Samsung’s strength in phones and tables also let it avoid a slump in PC demand that caused global chip sales to fall 3 percent last year to $297.6 billion, according to Gartner.

Six of the top 10 chip buyers cut spending last year because of the computer-sales slowdown, Gartner said.

Third-ranked Hewlett-Packard Co. (NYSE: HPQ) pared expenditure 13 percent to $14 billion, while fourth-placed Dell Inc. (Nasdaq: DELL) cut spending by a similar proportion to $8.6 billion.

Sony Corp. rose to fifth in the rankings from eighth after boosting spending 1.9 percent to $7.9 billion.

Lenovo’s chip purchases increased 0.3 percent.

Cisco (Nasdaq: CSCO) gained two spots in the rankings even though its purchases shrank by 0.8 percent.

“Although Samsung and Apple continue to go from strength to strength, other leading electronic equipment makers fared less well, and six of the top 10 reduced their demand in 2012,” Yamaji said.

“In addition to a weak macroeconomic situation, a dramatic change in consumer demand contributed to a reduction in semiconductor demand in 2012. The PC market still represented the largest sector for chip demand, but desktop and mobile PCs did not sell well, as consumers’ interest shifted to new mobile computing devices like smartphones and media tablets. This shift caused a substantial decrease in semiconductor demand in 2012, as the semiconductor content of a smartphone or a media tablet is far less than that of a PC.”