This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: CRIS: Add hardware support for __builtin_ctz
- From: Rask Ingemann Lambertsen <rask at sygehus dot dk>
- To: Jesper Nilsson <jesper dot nilsson at axis dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 4 Sep 2007 21:28:13 +0200
- Subject: Re: CRIS: Add hardware support for __builtin_ctz
- References: <20070904143048.GF5042@axis.com>
On Tue, Sep 04, 2007 at 04:30:48PM +0200, Jesper Nilsson wrote:
> One question mark still remaining is why the define_expand for
> ctzsi2 can't use the following:
>
> (define_expand "ctzsi2"
> [(set (match_scratch:SI 2)
> (match_operand:SI 0 "register_operand"))
> (set (match_dup 2)
> (unspec:SI [(match_dup 2)] CRIS_UNSPEC_SWAP_BITS))
> (set (match_operand:SI 0 "register_operand")
> (clz:SI (match_dup 2)))
> ]
> "TARGET_HAS_LZ && TARGET_HAS_SWAP"
> ""
> )
>
> If the above construction is used, I get an ICE in copy_rtx for the
> scratch operand...
It should be fine, so that's a bug. It's unusual to have a (set (scratch)
...) construct, which is probably why it hasn't been caught until now.
What is the ICE, btw?
Note that (match_operand "register_operand") won't match a (scratch ...)
expression. Thus you probably wouldn't get far even without the ICE in
copy_rtx.
> +(define_expand "ctzsi2"
> + [(set (match_dup 2)
> + (match_operand:SI 1 "register_operand"))
> + (set (match_dup 2)
> + (unspec:SI [(match_dup 2)] CRIS_UNSPEC_SWAP_BITS))
> + (set (match_operand:SI 0 "register_operand")
> + (clz:SI (match_dup 2)))]
> + "TARGET_HAS_LZ && TARGET_HAS_SWAP"
> + "operands[2] = gen_reg_rtx (SImode);"
> + )
This should result in better code because local-alloc and global-alloc
will know about the scratch register.
--
Rask Ingemann Lambertsen