U.S. inflation was 8.5% in July, decelerating from its highest annual rate in four decades as gasoline costs fell.