This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
LRA reload produces invalid insn
- From: Paul Koning <paulkoning at comcast dot net>
- To: GCC Development <gcc at gcc dot gnu dot org>
- Date: Thu, 1 Nov 2018 20:25:05 -0400
- Subject: LRA reload produces invalid insn
I'm running the testsuite on the pdp11 target, and I get a failure when using LRA that works correctly with the old allocator. The issue is that LRA is producing an insn that is invalid (it violates the constraints stated in the insn definition).
The insn in the IRA dump looks like this:
(insn 240 238 241 13 (set (reg/f:HI 155)
(plus:HI (reg/f:HI 5 r5)
(const_int -58 [0xffffffffffffffc6]))) "/Users/pkoning/Documents/svn/combined/gcc/testsuite/gcc.c-torture/execute/builtins/strcat-chk.c":68:7 68 {addhi3}
(expr_list:REG_EQUIV (plus:HI (reg/f:HI 5 r5)
(const_int -58 [0xffffffffffffffc6]))
(nil)))
(note that R5 is FRAME_POINTER_REGNUM.)
The reload dump from LRA shows this:
(insn 240 238 241 13 (set (reg/f:HI 5 r5 [155])
(plus:HI (reg/f:HI 6 sp)
(const_int 12 [0xc]))) "/Users/pkoning/Documents/svn/combined/gcc/testsuite/gcc.c-torture/execute/builtins/strcat-chk.c":68:7 68 {addhi3}
(expr_list:REG_EQUIV (plus:HI (reg/f:HI 5 r5)
(const_int -58 [0xffffffffffffffc6]))
(nil)))
But that's not valid because ADD is a two-operand instruction:
(define_insn_and_split "addhi3"
[(set (match_operand:HI 0 "nonimmediate_operand" "=rR,rR,Q,Q")
(plus:HI (match_operand:HI 1 "general_operand" "%0,0,0,0")
(match_operand:HI 2 "general_operand" "rRLM,Qi,rRLM,Qi")))]
The old allocator produces two insns for this:
(insn 443 238 240 13 (set (reg/f:HI 5 r5 [155])
(const_int 12 [0xc])) "/Users/pkoning/Documents/svn/combined/gcc/testsuite/gcc.c-torture/execute/builtins/strcat-chk.c":68:7 25 {movhi}
(nil))
(insn 240 443 241 13 (set (reg/f:HI 5 r5 [155])
(plus:HI (reg/f:HI 5 r5 [155])
(reg/f:HI 6 sp))) "/Users/pkoning/Documents/svn/combined/gcc/testsuite/gcc.c-torture/execute/builtins/strcat-chk.c":68:7 68 {addhi3}
(expr_list:REG_EQUIV (plus:HI (reg/f:HI 6 sp)
(const_int 12 [0xc]))
(nil)))
which is the correct sequence given the matching operand constraint in the define_insn.
Is this an LRA bug, or is there something I need to do in the target to prevent this happening?
paul