Gasoline prices in the U.S. on Tuesday topped $4 a gallon on average for the first time in more than three years, the latest sign of how the Iran war is driving up fuel costs for U.S. motorists.