public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* define_insn : order of matching patterns
@ 2001-12-04  5:46 jeroen dobbelaere
  2001-12-04  6:55 ` Alexandre Oliva
  0 siblings, 1 reply; 3+ messages in thread
From: jeroen dobbelaere @ 2001-12-04  5:46 UTC (permalink / raw)
  To: gcc

Hi,

I'm trying to let 'arm-linux-gcc -mcpu=xscale' produce 'smlabb' instructions.
(using gcc-3.0.2)


In 'arm.md', we have following description :

(define_insn "*mulhisi3addsi"
   [(set (match_operand:SI 0 "s_register_operand" "=r")
	(plus:SI (match_operand:SI 1 "s_register_operand" "r")
		 (mult:SI (sign_extend:SI
			   (match_operand:HI 2 "s_register_operand" "%r"))
			  (sign_extend:SI
			   (match_operand:HI 3 "s_register_operand" "r")))))]
   "TARGET_ARM && arm_is_xscale"
   "smlabb%?\\t%0, %2, %3, %1"
   [(set_attr "type" "mult")]
)


But with this, I don't succeed in producing 'smlabb' for a simple example

int test(volatile short a, volatile short b, int length)
{
   int result=0;
   while(length >0)
     {
       result += (int)a*(int)b;
     }

   return result;
}



After duplicating the pattern into :

(define_insn "*mulhisi3addsi_left"
   [(set (match_operand:SI 0 "s_register_operand" "=r")
	(plus:SI (match_operand:SI 1 "s_register_operand" "r")
		 (mult:SI (sign_extend:SI
			   (match_operand:HI 2 "'ts_register_operand" "%r"))
			  (sign_extend:SI
			   (match_operand:HI 3 "s_register_operand" "r")))))]
   "TARGET_ARM && arm_is_xscale"
   "smlabb%?\\t%0, %2, %3, %1"
   [(set_attr "type" "mult")]
)

(define_insn "*mulhisi3addsi_right"
   [(set (match_operand:SI 0 "s_register_operand" "=r")
	(plus:SI (mult:SI (sign_extend:SI
			   (match_operand:HI 1 "s_register_operand" "%r"))
			  (sign_extend:SI
			   (match_operand:HI 2 "s_register_operand" "r")))
		 (match_operand:SI 3 "s_register_operand" "r")
		 ))]
   "TARGET_ARM && arm_is_xscale"
   "smlabb%?\\t%0, %1, %2, %3"
   [(set_attr "type" "mult")]
)


I finally succeed in producing 'smlabb' instructions. It seems that
only '*mulhisi3addsi_right' is used for this.

Now my questions :

1. Why doesn't the original pattern ('*mulhisi3addsi_left') get a match ?
Looking at the instructions in 14.life, it seems that '*mulhisi3addsi_left'
should match, as reg38, generated in insn 37, is the right operand of 'plus:SI'.
But, it instead, '*mulhisi3addsi_right' is matched, which uses the 'mult' pattern
in the left operand of 'plus:SI'

<From 14.life>

(insn 37 36 39 (set (reg:SI 38)
         (mult:SI (sign_extend:SI (reg:HI 36))
             (sign_extend:SI (reg:HI 37)))) 56 {mulhisi3} (insn_list 34 (insn_list 36 (nil)))
     (expr_list:REG_DEAD (reg:HI 36)
         (expr_list:REG_DEAD (reg:HI 37)
             (nil))))

(insn 39 37 40 (set (reg/v:SI 35)
         (plus:SI (reg/v:SI 35)
             (reg:SI 38))) 4 {*arm_addsi3} (insn_list 37 (nil))
     (expr_list:REG_DEAD (reg:SI 38)
         (nil)))


<From 15.combine>

(note 37 36 39 NOTE_INSN_DELETED 0)

(insn 39 37 40 (set (reg/v:SI 35)
         (plus:SI (mult:SI (sign_extend:SI (reg:HI 36))
                 (sign_extend:SI (reg:HI 37)))
             (reg/v:SI 35))) 58 {*mulhisi3addsi_right} (insn_list 36 (insn_list 34 (nil)))
     (expr_list:REG_DEAD (reg:HI 37)
         (expr_list:REG_DEAD (reg:HI 36)
             (nil))))



2. Can I savely remove the '*mulhisi3addsi_left' part, or should I provide
both cases ?


Greetings,
--
Jeroen Dobbelaere
Embedded Software Engineer

ACUNIA Embedded Solutions
http://www.acunia.com


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

* Re: define_insn : order of matching patterns
  2001-12-04  5:46 define_insn : order of matching patterns jeroen dobbelaere
@ 2001-12-04  6:55 ` Alexandre Oliva
  2001-12-04  7:52   ` jeroen dobbelaere
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Oliva @ 2001-12-04  6:55 UTC (permalink / raw)
  To: jeroen dobbelaere; +Cc: gcc

On Dec  4, 2001, jeroen dobbelaere <jeroen.dobbelaere@acunia.com> wrote:

> 1. Why doesn't the original pattern ('*mulhisi3addsi_left') get a match ?

Read about pattern canonicalization in the GCC manual.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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

* Re: define_insn : order of matching patterns
  2001-12-04  6:55 ` Alexandre Oliva
@ 2001-12-04  7:52   ` jeroen dobbelaere
  0 siblings, 0 replies; 3+ messages in thread
From: jeroen dobbelaere @ 2001-12-04  7:52 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gcc

Alexandre Oliva wrote:

> On Dec  4, 2001, jeroen dobbelaere <jeroen.dobbelaere@acunia.com> wrote:
> 
> 
>>1. Why doesn't the original pattern ('*mulhisi3addsi_left') get a match ?
>>
> 
> Read about pattern canonicalization in the GCC manual.
> 
> 

Ok. Found it there :

<http://gcc.gnu.org/onlinedocs/gcc_21.html#SEC246>

     * For commutative and comparison operators, [..]
       if only one operand is a neg, not, mult, plus, or minus expression, it will be the first operand.

Thanks !

--
Jeroen Dobbelaere
Embedded Software Engineer

ACUNIA Embedded Solutions
http://www.acunia.com


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

end of thread, other threads:[~2001-12-04 15:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-04  5:46 define_insn : order of matching patterns jeroen dobbelaere
2001-12-04  6:55 ` Alexandre Oliva
2001-12-04  7:52   ` jeroen dobbelaere

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).