The following snippet illustrates the problem.
During register allocation, the value defined at 868 for vreg154:isub_hi (lane mask 0x0001) is extended to the use at 1564 via a single segment. That segment spans over the entry to BB#6, which is reachable from two places: the end of BB#5 (dominated by 868), and the end of BB#6. The value of vreg154:isub_hi is undefined when coming from the end of BB#6, which causes the verifier to complain.
To fix this, create a PHI when a defined value is merged with an undef value at the entry to a block. Currently, undef values are simply ignored when determining the need for PHIs, which leads to a problem when there is a unique defined value.
704B BB#5: derived from LLVM BB %b17
Predecessors according to CFG: BB#2 BB#4
868B %vreg154<def> = COPY %vreg148; DoubleRegs:%vreg154,%vreg148
Successors according to CFG: BB#6(?%)
1172B BB#6: derived from LLVM BB %b30
Predecessors according to CFG: BB#5 BB#6
1212B %vreg66<def> = C2_cmpgt %vreg152, %vreg154:isub_lo; PredRegs:%vreg66 IntRegs:%vreg152 DoubleRegs:%vreg154
1564B %vreg153<def> = COPY %vreg154; DoubleRegs:%vreg153,%vreg154
1572B %vreg154<def> = COPY %vreg153; DoubleRegs:%vreg154,%vreg153
1856B %vreg154:isub_lo<def,read-undef> = A2_addi %vreg154:isub_lo, 1; DoubleRegs:%vreg154
1984B J2_jump <BB#6>, %PC<imp-def,dead>
Successors according to CFG: BB#6(?%)
# End machine code for function fred.
*** Bad machine code: Register not marked live out of predecessor ***
- function: fred
- basic block: BB#6 b30 (0x50bb8b8) [1172B;1992B)
- liverange: [868r,1564r:1)[1572r,1572d:0) 0@1572r 1@868r
- v. register: %vreg154
- lanemask: 00000001
- ValNo: 1 (def 868r)
live into BB#6@1172B, not live before 1992B
LLVM ERROR: Found 1 machine code errors.