Agreed. It depends on the factors involved.
I once had a mid 80's Mustang GT with a stock engine that would get about 20 mpg Hwy. I swapped the motor for another one utilizing higher compression heads with an aftermarket high-performance valve train, a higher performance cam, high-performance intake manifold, after-market full length tube headers, and a block that had been bored over standard to accommodate high-performance pistons with custom Total Seal rings. The intake, heads, and headers were all smoothed and port-matched to improve flow efficiency. Altogether, I netted an increase of about 155 hp. The improved flow efficiency and power-to-weight ratio of the new engine in the same car meant that the new engine didn't have to work as hard and my Hwy mileage as a result went up from about 20 to 28-30.