public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Uros Bizjak <ubizjak@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [RFC] Slightly fix up vgather* patterns
Date: Mon, 10 Oct 2011 21:04:00 -0000	[thread overview]
Message-ID: <4E9359F5.5030609@redhat.com> (raw)
In-Reply-To: <20111008154322.GQ19412@tyan-ft48-01.lab.bos.redhat.com>

On 10/08/2011 08:43 AM, Jakub Jelinek wrote:
>  (define_expand "avx2_gathersi<mode>"
> -  [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "")
> -	(unspec:VEC_GATHER_MODE
> -	  [(match_operand:VEC_GATHER_MODE 1 "register_operand" "")
> -	   (match_operand:<ssescalarmode> 2 "memory_operand" "")
> -	   (match_operand:<VEC_GATHER_MODE> 3 "register_operand" "")
> -	   (match_operand:VEC_GATHER_MODE 4 "register_operand" "")
> -	   (match_operand:SI 5 "const1248_operand " "")]
> -	  UNSPEC_GATHER))]
> +  [(parallel [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "")
> +		   (unspec:VEC_GATHER_MODE
> +		     [(match_operand:VEC_GATHER_MODE 1 "register_operand" "")
> +		      (match_operand:<ssescalarmode> 2 "memory_operand" "")
> +		      (match_operand:<VEC_GATHER_MODE> 3 "register_operand" "")
> +		      (match_operand:VEC_GATHER_MODE 4 "register_operand" "")
> +		      (match_operand:SI 5 "const1248_operand " "")]
> +		     UNSPEC_GATHER))
> +	      (clobber (match_dup 4))])]
>    "TARGET_AVX2")

The use of match_dup in the clobber is wrong.  We should not be
clobbering the user-visible copy of the operand.  That does not
make sense when dealing with the user-visible builtin.


>  
>  (define_insn "*avx2_gathersi<mode>"
> -  [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=x")
> +  [(set (match_operand:VEC_GATHER_MODE 0 "register_operand" "=&x")
>  	(unspec:VEC_GATHER_MODE
> -	  [(match_operand:VEC_GATHER_MODE 1 "register_operand" "0")
> +	  [(match_operand:VEC_GATHER_MODE 2 "register_operand" "0")
>  	   (mem:<ssescalarmode>
> -	     (match_operand:P 2 "register_operand" "r"))
> -	   (match_operand:<VEC_GATHER_MODE> 3 "register_operand" "x")
> -	   (match_operand:VEC_GATHER_MODE 4 "register_operand" "x")
> -	   (match_operand:SI 5 "const1248_operand" "n")]
> -	  UNSPEC_GATHER))]
> +	     (match_operand:P 3 "register_operand" "r"))
> +	   (match_operand:<VEC_GATHER_MODE> 4 "register_operand" "x")
> +	   (match_operand:VEC_GATHER_MODE 5 "register_operand" "1")
> +	   (match_operand:SI 6 "const1248_operand" "n")]
> +	  UNSPEC_GATHER))
> +   (clobber (match_operand:VEC_GATHER_MODE 1 "register_operand" "=&x"))]
>    "TARGET_AVX2"
> -  "v<gthrfirstp>gatherd<gthrlastp>\t{%4, (%2, %3, %c5), %0|%0, (%2, %3, %c5), %4}"
> +  "v<gthrfirstp>gatherd<gthrlastp>\t{%1, (%3, %4, %c6), %0|%0, (%3, %4, %c6), %1}"
>    [(set_attr "type" "ssemov")
>     (set_attr "prefix" "vex")
>     (set_attr "mode" "<sseinsnmode>")])

Instead, use (clobber (match_scratch)) and matching constraints with operand 4.


> Still, the insn description is imprecise, saying that it loads from mem
> at the address register is wrong and perhaps some DCE might delete
> what shouldn't be deleted.  So, either it should (use (mem (scratch)))
> or something similar, or in the unspec list all the memory locations
> that are being read
> (mem:<scalarssemode> (plus:SI (reg:SI) (vec_select:SI (match_operand:V4SI)
> (parallel [(const_int N)]))))
> for N 0 through something (but it is complicated by Pmode size vs.
> the need to do nothing/truncate/sign_extend the vec_select to the right
> mode).

I think that a (mem (scratch)) as input to the unspec is probably best.
The exact memory usage is almost certainly too complex to describe
in a useful way.


r~

  parent reply	other threads:[~2011-10-10 20:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-08 15:50 Jakub Jelinek
2011-10-09 11:48 ` Uros Bizjak
2011-10-10  8:38   ` Jakub Jelinek
2011-10-10 21:04 ` Richard Henderson [this message]
2011-10-12 19:16   ` [PATCH] Slightly fix up vgather* patterns (take 2) Jakub Jelinek
2011-10-12 20:57     ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E9359F5.5030609@redhat.com \
    --to=rth@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=ubizjak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).