Enormous spending on artificial intelligence infrastructure has driven the entire stock market higher in recent years.