Double-edged sword on buildings, and limited effects. Lighty-built buildings, of course, are gone; reinforced-concrete buildings, lot of holes. They do as fair amount of damage to buildings, but can kill a lot of civilians hiding in them (so do HMGs as well, but they don't penetrate nearly as far and of course they don't explode). This of course defeats the purpose of sending in infantry to clear out the bad guys and avoid civillian losses; otherwise, ruthless armies just use main tank guns, artillery, bombs, and the like, and level the whole building, bad guys and civilians inclusive. Yo can use autocannons against infantry in trenches and in the open, but you use up a lot of ammo to do so, and machine guns are more efficient for the latter. ATGMs do more damage against trenches and bunkers than autocannons. but an autocannon does let you get off a decent snap-shot at enemy ATGM or heavy-weapons crew at a longer range than HMG, and with explosive effects at that. Big bonus.
Tanks are best to use against otherwise invulnerable enemy positions in buildings. Autocannons may, or may not, take the positions out, but you have to risk a vehicle with less-than-MBT level armour to do it. A (rifled) tank gun firing HESH is the best for this; various-MP, HE, HE-FRAG, and HEAT are also useful, but not as good (but can be fired by smoothbore tank guns). And an MBT (or at least a tracked vehicle with MBT-level armour) can often be used against enemy positions that have anti-tank weapons (it sounds ironic, but with their frontal protection, tanks can be risked to dart out, take a quick snap-shot at an enemy AT position and destroy it, then dart back behind cover - you wouldn't risk that with any APC or IFV that isn't converted from or built on an MBT chassis and hull with the same armour fitted).
Just to be clear on the advantages of 20-40mm autocannons over 12.7mm-15.5mm HMG, autocannons give you an ability to destroy with quick snap-shooting light armour anywhere from a mile to maybe two to two-and-a half miles under ideal conditions; HMGs can manage this only up to a mile at most, and with the best-protected IFVs, only up to a quarter-mile, or not all (in case of .50 cal/12.7mm). IFVs (and APCs) were orginally designed to keep out .50-cal/12.7mm along at least their frontal arcs, and preferably 14.5mm as well; in practice, HMGs were often able to penetrate such armour, so IFVs increased to the same weight as WWII medium tanks M-4 Sherman and T-34 (and surpassed Pz IV) to do so.
Now IFVs are being armoured to withstand 30mm along their frontal arcs, and their weight is now equalling or surpassing T-54/T-55 and approaching T-62. To penetrate this frontal armour, many countries have gone to 40 mm(Swedish/Scandanavian CV-90) or are upgrading to it (British Warrior). This adds even more weight and takes up even more internal space (bigger gun, and 40mm ammo is twice the size of 30mm ammo). An IFV can carry only about 400 rounds of 25mm Bushmaster ammo; theoretically, it can burn trhrough this in an hour to a 2 hours' worth of heavy fighting, maybe a lot less - but with a 40mm gun, it can only carry half that amount, and could run out of ammo in half that time easily. Plus, given that IFV's are now being armoured against 30mm, anything much short of the 40mm either can't penetrate the frontal armour, or can only do so at a fraction of the expected range (so instead of a kill at 2,200 m with 25mm APFSDS for example, maybe only at 500m or so, if that).
And of course all this space taken up by autocannons and their ammo leaves less space for ATGM (which are the only thing more-or-less "guaranteed" to take out the most heavily armoured IFVs at any range from any angle) and of course for the infantry themselves.
An Autocannon does give much greater range an firepower than HMGs, but it is really just an over-sized, glorified HMG that can fire exploding ammo at a grater range. It can do the same things as an HMG, and better, but at a heavy cost; there is little or nothing you can use an Autocannon on that you can't use an HMG on. And given how IFVs are approaching MBTs in weight as they need to increase their armour against larger autocannons, thus rendering smaller autocannons ineffectve except at close range, the weight and space for an autocannon is probably best saved for a fire-and-forget ATGM and its Surveillance and Fire Control System, slaved to an HMG. As I stated near the beginning, the only real advantage that I see an Autocannon having over an HMG, and a potentiall big one at that, is the ability to quickly take out an enemy heavy-weapons or ATGM crew a mile or two away; HMG can only do that at half-a-mile to a mile.
PM Pointblank on the subject of autocannons; he may give you a very different answer than me, but the answer he will give you will be an informed one at least.