There are a couple main (safety) concerns with this: the pieces moving while cutting and the offcuts getting caught in the blade.
Pieces moving while cutting
This is not so much an issue with safety as it is with accuracy. If one (or all) of the pieces move, you'll need to redo the cut on at least one of the boards, potentially negating any time savings you would see by cutting multiple pieces at once. Risk is negligible if everything is clamped.
Offcuts getting caught in the blade
This is probably not as much an issue on a miter saw as it is on other powered saws. Offcuts always have a change to get caught in the blade, although this situation is riskier since you are continuing to cut after an offcut is made. Typically, your offcut would become free at the end of the cut, at which point you turn off the saw. In this case, though, you are continuing to cut, so you have to be aware of what those offcuts are doing (and where your board is pushing them). With a miter saw, the blade is probably moving away from the offcuts, so likely not a big risk. Clamping again can reduce this (clamp both the "keep" side and the offcut side), but does introduce a potential problem with binding.
Thanks to @JacobEdmond for pointing out that stacking the pieces vertically on a miter saw can lead to the offcuts falling into the blade. Positioning the pieces in front of each other leads to a much safer cut.
For the same reason you don't want to run a piece in a crosscut sled against the fence (use an offset fence instead), you want to be careful about confining the pieces too much after the cut. You don't want the offcuts to get caught in the blade, but a loose offcut in the blade is much better than an offcut which is confined - that leads to flying wood and other Bad Things.
Your bigger issue is likely to be accuracy
Getting 2 (or 3 or more) boards lined up exactly together, with a stop block, clamp, or other registration device, is likely to take a relatively long time in order to make an accurate cut. More time, likely, than just setting up a stop block and making 40 "single" cuts instead of 20 "double" cuts in the first place. In addition (thanks again to @JacobEdmond), any error in your miter saw setup (blade angle, bevel angle, etc) will be amplified across the bigger cut.
Consider the time to line up the pieces, put a clamp on, butt up against the stop block (or measure with a tape and mark), ensure the pieces are still lined up, and cut. Compare that to the time to butt the piece up against the stop block and cut.
So, while it can be done relatively safely, it may not gain you much in terms of speed - unless your tolerances are fairly loose.