From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31634 invoked by alias); 15 Aug 2014 01:21:31 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 31614 invoked by uid 89); 15 Aug 2014 01:21:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-la0-f45.google.com Received: from mail-la0-f45.google.com (HELO mail-la0-f45.google.com) (209.85.215.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 15 Aug 2014 01:21:27 +0000 Received: by mail-la0-f45.google.com with SMTP id ty20so1827564lab.18 for ; Thu, 14 Aug 2014 18:21:23 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.34.78 with SMTP id x14mr8608811lbi.38.1408065683701; Thu, 14 Aug 2014 18:21:23 -0700 (PDT) Received: by 10.152.29.134 with HTTP; Thu, 14 Aug 2014 18:21:23 -0700 (PDT) Date: Fri, 15 Aug 2014 01:21:00 -0000 Message-ID: Subject: help with fusing multiple dependent ops in gcc combine pass From: Cherry Vanc To: gcc-help@gcc.gnu.org Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00107.txt.bz2 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