How to write shift and add pattern?

Richard Henderson rth@redhat.com
Fri Nov 6 16:17:00 GMT 2009


On 11/06/2009 05:29 AM, Mohamed Shafi wrote:
>      The target that i am working on has 1&  2 bit shift-add patterns.
> GCC is not generating shift-add patterns when the shift count is 1. It
> is currently generating add operations. What should be done to
> generate shift-add pattern instead of add-add pattern?

I'm not sure.  You may have to resort to matching

   (set (match_operand 0 "register_operand" "")
        (plus (plus (match_operand 1 "register_operand" "")
		   (match_dup 1))
              (match_operand 2 "register_operand" ""))))

But you should debug make_compound_operation first to
figure out what's going on for your port, because it's
working for x86_64:

	long foo(long a, long b) { return a*2 + b; }

	leaq	(%rsi,%rdi,2), %rax	# 8	*lea_2_rex64
	ret				# 26	return_internal


r~



More information about the Gcc mailing list