public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* help with fusing multiple dependent ops in gcc combine pass
@ 2014-08-15  1:21 Cherry Vanc
  2014-08-15  5:16 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Cherry Vanc @ 2014-08-15  1:21 UTC (permalink / raw)
  To: gcc-help

 I received very helpful comments previously
(https://gcc.gnu.org/ml/gcc-help/2014-08/msg00010.html). And I could
successfully fuse dependent ops like following :

...
r1 = (r1) op1 (const)
...
...
r1 = (r1) op2 (r2)
...
...
r3 = op3 (r1)
...

using a define_insn pattern to a new op "testnew36".

Now, How can I fuse the following stream of ops :

...
op1
...
op2 (consumes result of op1)
...
op3 (consumes result of op2)
...
op4 (consumes result of op2)
...

to the following :

...
testnew36
...
testnew40

The pertinent pattern seen in .combine file is a parallel expression :

(parallel [
        (set (reg:DI 256 [ *_15 ])
            (op3:DI (op2:DI (op1:DI (reg:DI 202 [ D.1563 ])
                        (const_int 4 [0x4]))
                    (reg:DI 242 [ inbuf ])) ))
        (set (reg:DI 205 [ D.1566 ])
            (op2:DI (op1:DI (reg:DI 202 [ D.1563 ])
                    (const_int 4 [0x4]))
                (reg:DI 242 [ inbuf ])))
    ])

Is the following the correct way to do combine the four ops :
1. define a new define_insn "*matchtestnewparallel" matching the above
parallel expression which substitutes the first set expression above
(op1+op2+op3 combination) with testnew36 and leaves the second set
expression (op1+op2) as is
2. define a new define_insn "*testnew40" pattern that matches op1 +
op2 + op4 combination.
(I already have a define_insn "*testnew36" pattern that matches
op1+op2+op3 combo.

I have done what I have just described above, but I am not quite
seeing what is desirable. The order in which I defined them in the md
file is - "*matchtestnewparallel", "*testnew40", "*testnew36". Either
I am not doing it right or this is just not the right way to do it.
Can you give me some hints please ?

Thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: help with fusing multiple dependent ops in gcc combine pass
  2014-08-15  1:21 help with fusing multiple dependent ops in gcc combine pass Cherry Vanc
@ 2014-08-15  5:16 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2014-08-15  5:16 UTC (permalink / raw)
  To: Cherry Vanc, gcc-help

On 08/14/14 19:21, Cherry Vanc wrote:
>   I received very helpful comments previously
> (https://gcc.gnu.org/ml/gcc-help/2014-08/msg00010.html). And I could
> successfully fuse dependent ops like following :
>
> ...
> r1 = (r1) op1 (const)
> ...
> ...
> r1 = (r1) op2 (r2)
> ...
> ...
> r3 = op3 (r1)
> ...
>
> using a define_insn pattern to a new op "testnew36".
>
> Now, How can I fuse the following stream of ops :
>
> ...
> op1
> ...
> op2 (consumes result of op1)
> ...
> op3 (consumes result of op2)
> ...
> op4 (consumes result of op2)
> ...
>
> to the following :
>
> ...
> testnew36
> ...
> testnew40
>
> The pertinent pattern seen in .combine file is a parallel expression :
>
> (parallel [
>          (set (reg:DI 256 [ *_15 ])
>              (op3:DI (op2:DI (op1:DI (reg:DI 202 [ D.1563 ])
>                          (const_int 4 [0x4]))
>                      (reg:DI 242 [ inbuf ])) ))
>          (set (reg:DI 205 [ D.1566 ])
>              (op2:DI (op1:DI (reg:DI 202 [ D.1563 ])
>                      (const_int 4 [0x4]))
>                  (reg:DI 242 [ inbuf ])))
>      ])
If you see a PARALLEL, then it means that one of the output operands in 
the original series of insns is used later.     Thus that side effect 
must be preserved.  In the example above, you'll find uses of regs 256 
and 205.

PARALLELs are typically far less useful because targets typically don't 
have many instructions that produce multiple outputs.  Typically when a 
PARALLEL is generated, you're going to be outputting multiple 
instructions for the PARALLEL.  In that case you're better off using a 
define_insn_and_split.  You can find many examples in the various MD 
files distributed with GCC.

If all the intermediate destinations die when they are consumed, then 
the combiner will not need to preserve the side effects and thus won't 
generate a PARALLEL and you would implement that as a simple define_insn 
in the machine description.  Again, you can find many examples of 
patterns for the combiner in the various MD files included in GCC.


Jeff


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-15  5:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-15  1:21 help with fusing multiple dependent ops in gcc combine pass Cherry Vanc
2014-08-15  5:16 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).