Advanced Micro Devices Inc posted better-than-expected second-quarter results as corporate spending on tech hardware strengthened, sending its shares up 4 percent after hours.

AMD's earnings report came two days after far larger rival Intel Corp set a bright tone for semiconductor industry earnings, signaling a resurgence of IT enterprise spending after years of straitened budgets.

AMD President and CEO Dirk Meyer said the strong earnings report was a reflection of demand for the company's combination of microprocessor and graphics chips and its recently launched Vision platform for notebooks.

AMD said on Thursday that revenue rose 40 percent to $1.65 billion in the period, beating expectations of $1.55 billion according to Thomson Reuters I/B/E/S.

It posted net income, excluding items, of $83 million, or 11 cents a share, versus a net loss of $244 million, or 37 cents a share, in the year-ago period. That surpassed expectations for 6 cents a share.

AMD joins Intel in exceeding Wall Street expectations for sales. Patrick Wang, analyst with Wedbush Securities, said there was a disconnect between what analysts had expected from Intel and AMD earnings and what the companies reported.

I'm kind of curious where all these (computers) are going. Maybe everybody in China has two computers now, Wang said.

There continues to be a disconnect here in terms of overall demand shipments.

Looking forward, AMD estimated a seasonal rise in third-quarter revenue. Analysts had been expecting revenue of $1.66 billion for the period.

AMD's gross margin rose to 45 percent from 27 percent in the year-ago period and 43 percent in the first quarter. Profitability has steadily improved since AMD spun off its chip manufacturing arm last year.

If they can walk the margins up in the back half of the year, you're going to get a lot of investors that are more bullish on the name, Wang said.

Shares of Sunnyvale, California-based AMD rose 3.9 percent to $7.70 in after-hours trading, after closing nearly flat at $7.41 on the New York Stock Exchange.

(Reporting by Alex Dobuzinskis: Editing by Richard Chang)