Issue with GCC reload

Henri Cloetens henri.cloetens@blueice.be
Wed Nov 4 10:05:00 GMT 2020


Hello all,

Continuing with my custom backend, I get another error. (during reload)

/home/henri/blueICe/gcc/newlib/newlib/libc/stdlib/ldtoa.c:1128:1: error: 
unable to generate reloads for:
  1128 | }
       | ^
 > (insn 247 246 298 14 (set (mem/c:SI (plus:SI (reg/f:SI 67 sfp)
 >                 (const_int 32 [0x20])) [40 %sfp+32 S4 A32])
 >        (zero_extend:SI (mem:HI (plus:SI (reg/v/f:SI 231 [ ldp ])
 >                   (const_int 76 [0x4c])) [1 MEM[(short unsigned int 
*)ldp_25(D) + 76B]+0 S2 A32])))
"/home/henri/blueICe/gcc/newlib/newlib/libc/stdlib/ldtoa.c":1124:14 43 
{zero_extendhisi2_internal}
      (expr_list:REG_DEAD (reg/v/f:SI 231 [ ldp ])

What happened is,
a. In the first pass, it put this in a register. Something like

   > (insn 247 246 298 14 (set (reg: SI 999)
 >        (zero_extend:SI (mem:HI (plus:SI (reg/v/f:SI 231 [ ldp ])
 >                   (const_int 76 [0x4c])) [1 MEM[(short unsigned int 
*)ldp_25(D) + 76B]+0 S2 A32])))

b. Then, during reload, it needs to move this to the stack. What I then 
found in the documentation,
     is the reload code calls my hook "blueproc_secondary_reload", and 
the hook then returns the
     instruction to do the reload with, and the register class of the 
register to use for the reload.
     Now, this is what my code logged for this call :

 > reload using movhi

 > blueproc_secondary_reload , return BASE_REGS, rclass = GENERAL_REGS, 
mode = HI, type 0 calls : 3667 x:
 > (mem:HI (plus:SI (reg/v/f:SI 231 [ ldp ])
 >         (const_int 76 [0x4c])) [1 MEM[(short unsigned int *)ldp_25(D) 
+ 76B]+0 S2 A32])

And .. there it goes wrong !. The hook returns the reload instruction 
"movhi", but here, because of the zero extend,
the other instruction is needed !. (zero_extendhisi2) The reason for 
this mistake is not in my code. The issue is, it
gets called with an incorrect RTX:

(mem:HI (plus:SI (reg/v/f:SI 231 [ ldp ])

This is not the operation the reload needs to do. On top of the memory 
load, the zero_extend is needed, but the
reload hook does not receive this. As a result, it returns the wrong 
instruction, and the compiler crashes.

Best Regards,

Henri.




More information about the Gcc-help mailing list