Walmart said higher-income shoppers are driving growth while lower-income households pull back, highlighting a widening K-shaped consumer economy.