Executives and major funds are selling shares in semiconductor and optical-communications companies after steep gains fueled by investor enthusiasm for artificial intelligence