Alex <cirru...@uol.com.br> writes: > 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" "") > ) > ) > ] > "" > "" > )
If you need a register, use a predicate of register_operand for one of the operands. Or use force_reg in the define_expand body. > 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. gcc is a complex tool. There are any number of reasons why this might happen. If you really want to know, -da will give you a lot of dump files to look over. Ian