This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: on define_peephole2


On 7/21/05, Liu Haibin <liu.haibin@gmail.com> wrote:
> Hi,
> 
> I have a problem on the define_peephole2. In nois2.md, there's such a
> define_insn
> 
> (define_insn "addsi3"
>   [(set (match_operand:SI 0 "register_operand"          "=r,r")
>         (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
>                  (match_operand:SI 2 "arith_operand"     "r,I")))]
>   ""
>   "add%i2\\t%0, %1, %z2"
>   [(set_attr "type" "alu")])
> 
> I defined a peephole2 to replace this instruction.
> 
> (define_peephole2
>   [(set (match_operand:SI 0 "register_operand" "=r")
>         (plus:SI (match_operand:SI 1 "register_operand" "%r")
> ;                (match_operand:SI 2 "arith_operand" "r")))]
>                  (match_operand:SI 2 "register_operand" "r")))]
>   ""
>   [(set (match_operand:SI 0 "register_operand" "=r")
>         (unspec_volatile:SI [(match_operand:SI 4 "custom_insn_opcode" "N")

my mistake. should be match_operand:SI 3 here. Now no more error.

>                         (match_operand:SI 1 "register_operand" "r")
>                         (match_operand:SI 2 "register_operand" "r")] CUSTOM_INII))]
>   "
> {
>         operands[4] = const0_rtx;
> }")
> 
> Because the operand 2 in the replacing instruction must be a register,
> I changed the "arith_operand" to "register_operand", hoping that it
> only replaces something like, add r1, r2, r3 instead of addi r1, r2, 9
> 
> I did a test with a file, which contains
> 
> (insn/f 106 73 107 0 0x0 (set:SI (reg/f:SI 27 sp)
>         (plus:SI (reg/f:SI 27 sp)
>             (const_int -16 [0xfffffff0]))) -1 (nil)
>     (nil))
> 
> and it seems that it did try to replace it with the new instruct. And
> I got the following error:
> 
> isqrt.c:65: error: unrecognizable insn:
> (insn 123 73 107 0 0x0 (set (reg/f:SI 27 sp)
>         (unspec_volatile:SI [
>                 (const_int 0 [0x0])
>                 (reg/f:SI 27 sp)
>                 (const_int -16 [0xfffffff0])
>             ] 117)) -1 (nil)
>     (nil))
> isqrt.c:65: internal compiler error: in extract_insn, at recog.c:2175
> 
> Any ideas why it still tries to replace it even when it's obviously
> not a register (const_int -16)? Thanks.
> 
> 
> Regards,
> Timothy
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]