From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5710 invoked by alias); 28 Aug 2009 14:28:46 -0000 Received: (qmail 5696 invoked by uid 22791); 28 Aug 2009 14:28:45 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 28 Aug 2009 14:28:37 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7SESZYQ002224; Fri, 28 Aug 2009 10:28:35 -0400 Received: from stone.twiddle.home (vpn-8-182.rdu.redhat.com [10.11.8.182]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7SESYt0012059; Fri, 28 Aug 2009 10:28:35 -0400 Message-ID: <4A97E98C.8040009@redhat.com> Date: Fri, 28 Aug 2009 23:49:00 -0000 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Thunderbird/3.0b3 MIME-Version: 1.0 To: Mohamed Shafi CC: GCC Subject: Re: How to write shift and add pattern? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-08/txt/msg00528.txt.bz2 On 08/28/2009 06:51 AM, Mohamed Shafi wrote: > Hello all, > > I am trying to port a 32bit arch in GCC 4.4.0. My target has support > for 1bit, 2bit shift and add operations. I tried to write patterns for > this , but gcc is not generating those. The following are the patterns > that i have written in md file: > > (define_insn "shift_add_" > [(set (match_operand:SI 0 "register_operand" "") > (plus:SI (match_operand:SI 3 "register_operand" "") > (ashift:SI (match_operand:SI 1 "register_operand" "") > (match_operand:SI 2 "immediate_operand" ""))))] > "" > "shadd1\\t%1, %0" > ) ... > Is GCC generating patterns with multiply due to > cost issues? I havent mentioned any cost details. No, it's merely using multiply because someone way back when decided that should be the canonical way to represent this. We canonicalize patterns so that the target file doesn't have to match both shifts and multiplies. So your insn should look like: (define_insn "*shadd1_si" [(set (match_operand:SI 0 "register_operand" "r") (plus:SI (mult:SI (match_operand:SI "register_operand" "r") (const_int 2)) (match_operand:SI "register_operand" "0")))] "" "shadd1 %1,%0") This should match even if your target doesn't support a hardware multiply insn. See also the shift-add patterns on the Alpha port. There we have 2 & 3 bit shifts. Search for const48_operand to find those patterns easily. r~