Taiwan Semiconductor Manufacturing Co. confirmed on Thursday that it is in talks to build its first ever chip facility in Japan.

The world's largest chipmaker said it is conducting due diligence on the project, a wafer production plant to be built in western Japan.

The news comes as TSMC reported a rise in net profit of almost 20% year-on-year for the April-June quarter, slightly missing analysts' forecast for the world's biggest contract chipmaker.

Net profit rose to 134.36 billion New Taiwan dollars ($4.81 billion), up 19.8% from a year ago, while revenue also grew nearly 20% on the year to NT$372.146 billion. Gross margin was 50% for the period, also slightly below the consensus forecast of 51.1%, compared with 53% in the same period last year.

The profit increase comes amid an unprecedented global chip shortage that is squeezing everyone from car companies to electronics makers, and which is spurring TSMC to invest heavily in expanding its output capacity.

The company in April said it will spend $2.8 billion to expand its chip facilities in the Chinese city of Nanjing, while in June it started construction of a $12 billion advanced semiconductor project in Arizona. TSMC has also committed to spending $100 billion through 2023 to expand production capacity.

The Taiwanese chip titan is also in the midst of a major shift in its long time strategy of concentrating its production in Taiwan. In addition to considering building its first chip plant in Japan, the company has promised to continue expanding its chip production in the U.S.

Washington pointed out in a recent supply chain review that the centralization of advanced chip production in Taiwan is a vulnerability in the semiconductor supply chain.

Some analysts worry that TSMC could see its profitability deteriorate because of its heavy capital spending now and in the next few years, while others are still optimistic about the company's outlook.

"We think margin pressure has gradually become a key concern ... We do not see the stock as attractive, even with its quality nature," Charlie Chan, an analyst with Morgan Stanley, said in a research note. Investing in TSMC's shares is "potentially dead money in the next 12-18 months," he added.

Mark Li, an analyst with Bernstein Research, said TSMC is likely to maintain its manufacturing leadership over the next few years.

"For mid- to long-term, we believe TSMC's outlook still stays strong. Despite the correction risk for the sector broadly next year, we believe TSMC is differentiated and won't be affected" the analyst said. "TSMC's engagement with Intel is progressing steadily and will help TSMC's revenue grow substantially in 2023."

Several other institutional investors including Citi, Credit Suisse and HSBC Bank ahead of earnings also shared relatively positive views but all were still concerned there could be market correction at some point.

TSMC's shares closed 0.16% higher at NT$614 on Thursday in Taipei. The chipmaking giant's shares have advanced more than 15% so far this year.