Andy,
You are probably right here – look at this – before phi elimination this code looks much more sane:
*** IR Dump After Live Variable Analysis ***:
Machine code for function push: SSA
Function Live Outs: %R0
BB#0: derived from LLVM BB %entry
%vreg5 = IMPLICIT_DEF; IntRegs:%vreg5
%vreg4 = TFRI_V4 ga:xx_stack; IntRegs:%vreg4
Successors according to CFG: BB#1
BB#1: derived from LLVM BB %for.cond
Predecessors according to CFG: BB#0 BB#1
%vreg0 = PHI %vreg4, <BB#0>, %vreg3, <BB#1>; IntRegs:%vreg0,%vreg4,%vreg3
%vreg1 = PHI %vreg5, <BB#0>, %vreg2, <BB#1>; IntRegs:%vreg1,%vreg5,%vreg2
%vreg2 = LDriw %vreg0, 0; mem:LD4[%stack.0.in] IntRegs:%vreg2,%vreg0
%vreg3 = ADD_ri %vreg2, 8; IntRegs:%vreg3,%vreg2
%vreg6 = CMPEQri %vreg2, 0; PredRegs:%vreg6 IntRegs:%vreg2
JMP_cNot %vreg6, <BB#1>, %PC; PredRegs:%vreg6
JMP <BB#2>
Successors according to CFG: BB#2 BB#1
BB#2: derived from LLVM BB %for.end
Predecessors according to CFG: BB#1
%vreg7 = LDriw %vreg1, 0; mem:LD4[%first1](tbaa=!“any pointer”) IntRegs:%vreg7,%vreg1
STriw_GP ga:yy_instr, 0, %vreg7; mem:ST4[@yy_instr](tbaa=!“any pointer”) IntRegs:%vreg7
%vreg8 = IMPLICIT_DEF; IntRegs:%vreg8
%R0 = COPY %vreg8; IntRegs:%vreg8
JMPR %PC, %R31, %R0<imp-use,kill>
Right after the dead vreg is introduced:
*** IR Dump After Eliminate PHI nodes for register allocation ***:
Machine code for function push: Post SSA
Function Live Outs: %R0
BB#0: derived from LLVM BB %entry
%vreg4 = TFRI_V4 ga:xx_stack; IntRegs:%vreg4
%vreg9 = COPY %vreg4; IntRegs:%vreg9,%vreg4
Successors according to CFG: BB#1
BB#1: derived from LLVM BB %for.cond
Predecessors according to CFG: BB#0 BB#1
%vreg0 = COPY %vreg9; IntRegs:%vreg0,%vreg9
%vreg1 = COPY %vreg10; IntRegs:%vreg1,%vreg10 <<<<<<<<<<<<<<<<<<<<<<<<<<< Not defined on first iteration….
%vreg2 = LDriw %vreg0, 0; mem:LD4[%stack.0.in] IntRegs:%vreg2,%vreg0
%vreg3 = ADD_ri %vreg2, 8; IntRegs:%vreg3,%vreg2
%vreg6 = CMPEQri %vreg2, 0; PredRegs:%vreg6 IntRegs:%vreg2
%vreg9 = COPY %vreg3; IntRegs:%vreg9,%vreg3
%vreg10 = COPY %vreg2; IntRegs:%vreg10,%vreg2
JMP_cNot %vreg6, <BB#1>, %PC; PredRegs:%vreg6
JMP <BB#2>
Successors according to CFG: BB#2 BB#1
BB#2: derived from LLVM BB %for.end
Predecessors according to CFG: BB#1
%vreg7 = LDriw %vreg1, 0; mem:LD4[%first1](tbaa=!“any pointer”) IntRegs:%vreg7,%vreg1
STriw_GP ga:yy_instr, 0, %vreg7; mem:ST4[@yy_instr](tbaa=!“any pointer”) IntRegs:%vreg7
%vreg8 = IMPLICIT_DEF; IntRegs:%vreg8
%R0 = COPY %vreg8; IntRegs:%vreg8
JMPR %PC, %R31, %R0<imp-use,kill>
End machine code for function push.
So the problem is elsewhere after all…
I’ll keep on digging. Thanks.
Sergei