public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Kelvin Nilsen <kdnilsen@linux.vnet.ibm.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH,rs6000] Add built-in function support for Power9 byte instructions
Date: Tue, 15 Nov 2016 11:19:00 -0000	[thread overview]
Message-ID: <20161115111912.GC12325@gate.crashing.org> (raw)
In-Reply-To: <ab3a654d-f151-a37c-3c52-5c667f19dc34@linux.vnet.ibm.com>

Hi!

On Mon, Nov 14, 2016 at 04:43:35PM -0700, Kelvin Nilsen wrote:
> 	* config/rs6000/altivec.md (UNSPEC_CMPRB): New unspec value.
> 	(UNSPEC_CMPRB2): New unspec value.

I wonder if you really need both?  The number of arguments will tell
which is which, anyway?

> 	(cmprb_p): New expansion.

Not such a great name (now you get a gen_cmprb_p function which isn't
a predicate itself).

> 	(CMPRB): Add byte-in-range built-in function.
> 	(CMBRB2): Add byte-in-either_range built-in function.
> 	(CMPEQB): Add byte-in-set builtin-in function.

"builtin-in", and you typoed an underscore?

> +;; Predicate: test byte within range.
> +;; Return in target register operand 0 a non-zero value iff the byte
> +;; held in bits 24:31 of operand 1 is within the inclusive range
> +;; bounded below by operand 2's bits 0:7 and above by operand 2's
> +;; bits 8:15.
> +(define_expand "cmprb_p"

It seems you got the bit numbers mixed up.  Maybe just call it the low
byte, and the byte just above?

(And it always sets 0 or 1 here, you might want to make that more explicit).

> +;; Set bit 1 (the GT bit, 0x2) of CR register operand 0 to 1 iff the

That's 4, i.e. 0b0100.

> +;; Set operand 0 register to non-zero value iff the CR register named
> +;; by operand 1 has its GT bit (0x2) or its LT bit (0x1) set.
> +(define_insn "*setb"

LT is 8, GT is 4.  If LT is set it returns -1, otherwise if GT is set it
returns 1, otherwise it returns 0.

> +;; Predicate: test byte within two ranges.
> +;; Return in target register operand 0 a non-zero value iff the byte
> +;; held in bits 24:31 of operand 1 is within the inclusive range
> +;; bounded below by operand 2's bits 0:7 and above by operand 2's
> +;; bits 8:15 or if the byte is within the inclusive range bounded
> +;; below by operand 2's bits 16:23 and above by operand 2's bits 24:31.
> +(define_expand "cmprb2_p"

The high bound is higher in the reg than the low bound.  See the example
where 0x3930 is used to do isdigit (and yes 0x3039 would be much more
fun, but alas).

> +;; Predicate: test byte membership within set of 8 bytes.
> +;; Return in target register operand 0 a non-zero value iff the byte
> +;; held in bits 24:31 of operand 1 equals at least one of the eight
> +;; byte values represented by the 64-bit register supplied as operand
> +;; 2.  Note that the 8 byte values held within operand 2 need not be
> +;; unique. 

(trailing space)

I wonder if we really need all these predicate expanders, if it wouldn't
be easier if the builtin handling code did the setb itself?


Segher

  reply	other threads:[~2016-11-15 11:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14 23:43 Kelvin Nilsen
2016-11-15 11:19 ` Segher Boessenkool [this message]
2016-11-15 18:05   ` Kelvin Nilsen
2016-11-15 18:22     ` Segher Boessenkool
2016-11-15 19:16       ` Kelvin Nilsen
2016-11-15 20:19         ` Segher Boessenkool

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=20161115111912.GC12325@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kdnilsen@linux.vnet.ibm.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).