reload problem:

dimmy diwil@mail.ru
Mon Jan 21 14:26:00 GMT 2002


Fellows,
I faced with a problem which I cannot understand.
I define expander as:

--------------------------------------------------------------
(define_expand "subhi3"
  [(set (match_operand:HI 0 "nonimmediate_operand_msp430" "")
        (minus:HI (match_operand:HI 1 "nonimmediate_operand_msp430" "")
                  (match_operand:HI 2 "general_operand_msp430" "")))] 
  ""
  "")

(define_insn "*subhi3_1"
  [(set (match_operand:HI 0 "register_operand"          "=r")
        (minus:HI (match_operand:HI 1 "register_operand" "0")
                  (match_operand:HI 2 "memory_operand_msp430"   "m")))]
"(zero_shifted(operands[2]) || indexed_location(operands[2]))"
  "sub  @%E2, %0"
  [(set_attr "length" "1")
   (set_attr "cc" "set_czn")])

(define_insn "*subhi3_2"
  [(set (match_operand:HI 0 "memory_operand_msp430"          "=m")
        (minus:HI (match_operand:HI 1 "memory_operand_msp430" "0")
                  (match_operand:HI 2 "memory_operand_msp430" "m")))]
"(zero_shifted(operands[2]) || indexed_location(operands[2]))"
  "sub  @%E2, %0"
  [(set_attr "length" "2")
   (set_attr "cc" "set_czn")])

(define_insn "*subhi3_3"
  [(set (match_operand:HI 0 "nonimmediate_operand_msp430"          
"=m,m,m,m,r,r,r,r")
        (minus:HI (match_operand:HI 1 "nonimmediate_operand_msp430" 
"0,0,0,0,0,0,0,0")
                  (match_operand:HI 2 "general_operand_msp430"      
"m,r,P,i,m,r,P,i")))]
"!zero_shifted(operands[2]) && !indexed_location(operands[2])"
  "sub  %2, %0"
  [(set_attr "length" "3,2,2,3,2,1,1,2")
   (set_attr "cc"
"set_czn,set_czn,set_czn,set_czn,set_czn,set_czn,set_czn,set_czn")])
-----------------------------------------------------

and for a code like
-----
{
        unsigned  start;  // <- these two allocated on stack
        unsigned  x;
....
x = CCR2 - start;
...
}
------

I have an error:

main.c:55: Unable to generate reloads for:

(insn 111 146 113 (set (mem/f:HI (plus:HI (reg/f:HI 1 r1)
                (const_int 2 [0x2])) 0)
        (minus:HI (mem/v/f:HI (symbol_ref:HI ("*0x0176")) 0)
            (mem/f:HI (reg/f:HI 1 r1) 0))) 80 {*subhi3_2} (nil)
    (nil))
main.c:55: Internal compiler error in find_reloads, at reload.c:3486

Here predicates ended with '_msp430' are the same as without one, but 
handle volatile memory references.

zero_shifted and indexed_location both handle (mem:XX (reg:xx))

The 00.rtl dump gives:


(insn 111 109 113 (set (mem/f:HI (plus:HI (reg/f:HI 17 virtual-stack-vars)
                (const_int 2 [0x2])) 0)
        (minus:HI (mem/v/f:HI (symbol_ref:HI ("*0x0176")) 0)
            (mem/f:HI (reg/f:HI 17 virtual-stack-vars) 0))) -1 (nil)
    (nil))

So, the question is: Why gcc does not follow '0' constraint and tries to 
combine 3 different operands into one insn?

This is valid only if no optimization specified.
This is valid only is 'start' variable located at the frame bottom 
(frame grows upward).
Frame pointer == stack pointer (does not matter)

Thanks in advence,
Dmitry.







More information about the Gcc mailing list