expert

The copy executed on a path that did not need it

Leaving SSA places a copy on each incoming edge of a block containing phi nodes. A backend implements this by appending the copies to the end of the predecessor block, which is correct whenever the predecessor has one successor.

The symptom

A loop that accumulates into sum when a condition holds produces a value that is too large. The extra contribution comes from an iteration on which the condition was false. Disabling the optimizer does not change it, and the bug survives at every optimization level.

Commit first

Name the phase, and name the property of one CFG edge that makes this placement illegal. Draw the two-block shape where appending the copy to the predecessor is wrong, and say what has to be inserted to make it right.