Investors cheered the tech giant’s latest results showing that its huge investments in artificial intelligence are beginning to show returns.