This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CRIS: Add hardware support for __builtin_ctz


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]