public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@redhat.com>
To: Ira Rosen <IRAR@il.ibm.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [RFC] [patch] Support vectorization of min/max location pattern
Date: Thu, 08 Jul 2010 20:10:00 -0000	[thread overview]
Message-ID: <4C3630BD.3040807@redhat.com> (raw)
In-Reply-To: <OF8091E3DC.D51DEA78-ONC225775A.0063AA0D-C225775A.0064AF5D@il.ibm.com>

On 07/08/2010 11:19 AM, Ira Rosen wrote:
> It's minloc pattern, i.e., a loop that finds the location of the minimum:
> 
>   float  arr[N};
> 
>   for (i = 0; i < N; i++)
>     if (arr[i] < limit)
>       {
>         pos = i + 1;
>         limit = arr[i];
>       }
> 
> Vectorizer's input code:
> 
>   # pos_22 = PHI <pos_1(4), 1(2)>
>   # limit_24 = PHI <limit_4(4), 0(2)>
>   ...
>   pos_1 = [cond_expr] limit_9 < limit_24 ? pos_10 : pos_22;       //
> location
>   limit_4 = [cond_expr] limit_9 < limit_24 ? limit_9 : limit_24;  // min

Ok, I get it now.

So your thinking was that you needed the builtin to replace the
comparison portion of the VEC_COND_EXPR?  Or, looking again I see
that you don't actually use VEC_COND_EXPR, you use ...

> +  /* Create: VEC_DEST = (VEC_OPRND1 & MASK) | (VEC_OPRND2 & !MASK).  */ 

... explicit masking.  I.e. you assume that the return value of
the builtin is a bit mask of the full width, and that there's no
better way to implement the VEC_COND.

I wonder if it wouldn't be better to extend the definition
of VEC_COND_EXPR so that the comparison values can be of a 
different type than the data operands (with the caveat that the
number of elements should be the same -- i.e. 4-wide compare must
match 4-wide data movement).

I can think of 2 portability problems with your current solution:

(1) SSE4.1 would prefer to use BLEND instructions, which perform
    that entire (X & M) | (Y & ~M) operation in one insn.

(2) The mips C.cond.PS instruction does *not* produce a bitmask
    like altivec or sse do.  Instead it sets multiple condition
    codes.  One then uses MOV[TF].PS to merge the elements based
    on the individual condition codes.  While there's no direct
    corresponding instruction that will operate on integers, I
    don't think it would be too difficult to use MOV[TF].G or
    BC1AND2[FT] instructions to emulate it.  In any case, this 
    is again a case where you don't want to expose any part of
    the VEC_COND at the gimple level.


r~

  reply	other threads:[~2010-07-08 20:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-01  8:01 Ira Rosen
2010-07-06  7:15 ` Ira Rosen
2010-07-07 20:43   ` Richard Henderson
2010-07-08  7:34     ` Ira Rosen
2010-07-08  9:21       ` Richard Guenther
2010-07-08 17:15       ` Richard Henderson
2010-07-08 18:20         ` Ira Rosen
2010-07-08 20:10           ` Richard Henderson [this message]
2010-08-09  7:55             ` [patch] Support vectorization of min/max location pattern - take 2 Ira Rosen
2010-08-09 10:05               ` Richard Guenther
2010-08-09 10:58                 ` Ira Rosen
2010-08-09 11:01                   ` Richard Guenther
2010-08-09 11:03                     ` Richard Guenther
2010-08-09 12:33                     ` Ira Rosen
2010-11-19 15:53   ` [RFC] [patch] Support vectorization of min/max location pattern H.J. Lu
2010-12-15 20:27     ` H.J. Lu

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=4C3630BD.3040807@redhat.com \
    --to=rth@redhat.com \
    --cc=IRAR@il.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).