gcc backend beginner: only -O1 gives 'unrecongnizable insn' error

Alex cirrus75@uol.com.br
Tue Jan 12 20:23:00 GMT 2010


     Hi,

     I am a beginner on gcc backend. I was performing some experiments 
on .md file using a completly new backend set of files written by me. I 
end up on something I really could not understand. Regarding addition, I 
put the following code on my .md file:

(define_expand "addhi3"
   [(set (match_operand:HI 0 "nonimmediate_operand" "")
         (plus:HI (match_operand 1 "general_operand" "")
                  (match_operand 2 "general_operand" "")
         )
     )
   ]
   ""
   ""
)

(define_insn "*addhi3_2"
     [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,d")
               (plus:HI (match_operand:HI 1 "register_operand" "r,r,0")
                        (match_operand:HI 2 "nonmemory_operand" "r,K,K")
               )
    )]
   ""
   "@
    add \\t%0, %1, %2
    add \\t%0, %1, #%c2
    add \\t%0, #%c2"
)

    Using this code, gcc gives the following error only when I use -O1 
(for -O0, -O2 it works OK!):

(insn 16 14 17 0 (set (reg:HI 12)
         (plus:HI (mem/i:HI (symbol_ref:HI ("b") <var_decl 0x7fdad4a0 
b>) [0 b+0 S2 A16])
             (mem/i:HI (symbol_ref:HI ("a") [flags 0x2] <var_decl 
0x7fdad430 a>) [0 a+0 S2 A16]))) -1 (nil)
     (nil))

    I understood that gcc would like to have a insn which accepts "reg = 
mem + mem", but I really can not understand why gcc works OK with -O2 
and with -O0, but not with -O1.

thank you!
Alex Prado



More information about the Gcc mailing list