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]

Generated insns far from being optimal


Hello everybody,

I'm testing a very simple C program with my compiler, which does the
following:

i = 5;

(i being an integer)

The generated insns are the following:
(insn 8 3 9 (set (reg/f:SI 15)
        (symbol_ref:SI ("i"))) -1 (nil)
    (expr_list:REG_EQUAL (symbol_ref:SI ("i"))
        (nil)))

(insn 9 8 11 (set (mem/f:SI (reg/f:SI 15) 0)
        (const_int 5 [0x5])) -1 (nil)
    (nil))

It puts the adress of i into a pseudo-register, and then move the value
5 into the address pointed by this register. While it is correct, it'd
be much more interesting to directly have something like this (taken
from the i386 target generation):

(insn 9 3 12 (set (mem/f:SI (symbol_ref:SI ("i")) 0)
        (const_int 5 [0x5])) -1 (nil)
    (nil))

Where the value 5 is directly put into i.

My movsi define_insn is the following:
(define_insn "movsi"
        [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
              (match_operand:SI 1 "general_operand"       "rmi"))]
        ""
        "%0 <- %1")

I'm not feeling very at ease with GCC for now - but it looks like it
should match the immediate to memory sequence and output an optimal
insn, isn't it?

Checking my .h description file, I can't see anything that would
influence this behavior. Is my define_insn wrong? Does someone have a
pointer or a suggestion about this?

The complete description files can be found here, if usefull:

http://www.gnurou.org/camille.md
http://www.gnurou.org/camille.h
http://www.gnurou.org/camille.c

These are only a first draft - lots of stuff has been taken from others
targets in order to have a basic working compiler.

Thanks for any help,
Alex.
-- 
http://www.gnurou.org



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