Outputting Matrix blocks with grouped values based on Entries field id
Try something like:

{% set breadGroups = entry.breads | group('bread.first.id') %}

{% for breadId, blocks in breadGroups %}

    {% set sum = 0 %}

    {% for block in blocks %}

        {% set sum = sum + block.quantity %}

    {% endfor %}

    Total qty for Bread ID {{ breadId }}: {{ sum }}

 {% endfor %}


The group filter consumes a list &mdash; in this base, an array of Matrix blocks &mdash; and produces an array of arrays where the key is the grouping parameter, and the value is an array of items from the original list for which the group criteria matches the key.

c.f. Craft docs: http://buildwithcraft.com/docs/templating/filters#group