qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, Cornelia Huck <cohuck@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v1 3/5] s390x/tcg: Implement VECTOR FIND ELEMENT NOT EQUAL
Date: Mon, 20 May 2019 11:48:26 +0200	[thread overview]
Message-ID: <8b7454fb-3d82-fcae-8851-c6e19fb0c81a@redhat.com> (raw)
In-Reply-To: <fd16fc6d-8fae-795f-2226-99138eb5fd2a@linaro.org>

On 17.05.19 19:56, Richard Henderson wrote:
> On 5/15/19 1:31 PM, David Hildenbrand wrote:
>> Similar to VECTOR FIND ELEMENT EQUAL, however the search also stops on
>> any inequality. A match for inequality seems to have precedence over
>> a match for zero, because both elements have to be zero.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>>  target/s390x/helper.h            |  6 ++++
>>  target/s390x/insn-data.def       |  2 ++
>>  target/s390x/translate_vx.inc.c  | 31 +++++++++++++++++++
>>  target/s390x/vec_string_helper.c | 53 ++++++++++++++++++++++++++++++++
>>  4 files changed, 92 insertions(+)
> 
> Like the previous, only with
> 
> static inline uint64_t nonzero_search(uint64_t a, uint64_t m)
> {
>     return (((a & m) + m) | a) & ~m;
> }
> 
> for the inequality.
> 
> 
> r~
> 

It's a little bit more tricky. because we have to identify the smaller
element. Right now I have this

+static int vfene(void *v1, const void *v2, const void *v3, bool zs,
uint8_t es)
+{
+    const uint64_t mask = dup_const(es, -1ull >> (65 - (1 << es) * 8));
+    uint64_t a0, a1, b0, b1, e0, e1, z0, z1;
+    uint64_t first_zero = 16;
+    uint64_t first_inequal;
+    bool smaller = false;
+
+    a0 = s390_vec_read_element64(v2, 0);
+    a1 = s390_vec_read_element64(v2, 1);
+    b0 = s390_vec_read_element64(v3, 0);
+    b1 = s390_vec_read_element64(v3, 1);
+    e0 = nonzero_search(a0 ^ b0, mask);
+    e1 = nonzero_search(a1 ^ b1, mask);
+    first_inequal = match_index(e0, e1);
+
+    /* identify the smaller element */
+    if (first_inequal < 16) {
+        uint8_t enr = first_inequal / (1 << es);
+        uint32_t a = s390_vec_read_element(v2, enr, es);
+        uint32_t b = s390_vec_read_element(v3, enr, es);
+        smaller = a < b;
+    }
+
+    if (zs) {
+        z0 = zero_search(a0, mask);
+        z1 = zero_search(a1, mask);
+        first_zero = match_index(z0, z1);
+    }
+
+    /* zero out the destination vector */
+    s390_vec_write_element64(v1, 0, 0);
+    s390_vec_write_element64(v1, 1, 0);
+
+    if (first_zero == 16 && first_inequal == 16) {
+        s390_vec_write_element8(v1, 7, 16);
+        return 3;
+    } else if (first_zero < first_inequal) {
+        s390_vec_write_element8(v1, 7, first_zero);
+        return 0;
+    }
+    s390_vec_write_element8(v1, 7, first_inequal);
+    return smaller ? 1 : 2;
+}


-- 

Thanks,

David / dhildenb


  reply	other threads:[~2019-05-20  9:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15 20:31 [Qemu-devel] [PATCH v1 0/5] s390x/tcg: Vector Instruction Support Part 3 David Hildenbrand
2019-05-15 20:31 ` [Qemu-devel] [PATCH v1 1/5] s390x/tcg: Implement VECTOR FIND ANY ELEMENT EQUAL David Hildenbrand
2019-05-17 16:16   ` Richard Henderson
2019-05-20  9:51     ` David Hildenbrand
2019-05-22 11:01     ` David Hildenbrand
2019-05-22 11:09       ` Richard Henderson
2019-05-22 11:16         ` David Hildenbrand
2019-05-22 15:59           ` Richard Henderson
2019-05-22 18:16             ` David Hildenbrand
2019-05-22 18:46               ` Richard Henderson
2019-05-23  7:50                 ` David Hildenbrand
2019-05-23 12:27                   ` Richard Henderson
2019-05-23 12:34                     ` David Hildenbrand
2019-05-23 12:59                       ` David Hildenbrand
2019-05-23 13:50                         ` Richard Henderson
2019-05-23 10:58           ` Alex Bennée
2019-05-15 20:31 ` [Qemu-devel] [PATCH v1 2/5] s390x/tcg: Implement VECTOR FIND " David Hildenbrand
2019-05-17 16:47   ` Richard Henderson
2019-05-17 17:42     ` Richard Henderson
2019-05-20  9:17       ` David Hildenbrand
2019-05-15 20:31 ` [Qemu-devel] [PATCH v1 3/5] s390x/tcg: Implement VECTOR FIND ELEMENT NOT EQUAL David Hildenbrand
2019-05-17 17:56   ` Richard Henderson
2019-05-20  9:48     ` David Hildenbrand [this message]
2019-05-15 20:31 ` [Qemu-devel] [PATCH v1 4/5] s390x/tcg: Implement VECTOR ISOLATE STRING David Hildenbrand
2019-05-17 18:20   ` Richard Henderson
2019-05-15 20:31 ` [Qemu-devel] [PATCH v1 5/5] s390x/tcg: Implement VECTOR STRING RANGE COMPARE David Hildenbrand
2019-05-17 18:37   ` 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=8b7454fb-3d82-fcae-8851-c6e19fb0c81a@redhat.com \
    --to=david@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.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 NNTP newsgroup(s).