From: "Kewen.Lin" <linkw@linux.ibm.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
David Edelsohn <dje.gcc@gmail.com>,
Peter Bergner <bergner@linux.ibm.com>,
Michael Meissner <meissner@linux.ibm.com>
Subject: Re: [PATCH 2/2] rs6000: Refine integer comparison handlings in rs6000_emit_vector_compare
Date: Thu, 17 Nov 2022 15:52:26 +0800 [thread overview]
Message-ID: <e6035592-885c-1498-454e-411f83b01471@linux.ibm.com> (raw)
In-Reply-To: <20221116185827.GX25951@gate.crashing.org>
Hi Segher,
Thanks for the comments!
on 2022/11/17 02:58, Segher Boessenkool wrote:
> Hi!
>
> On Wed, Nov 16, 2022 at 02:51:04PM +0800, Kewen.Lin wrote:
>> The current handlings in rs6000_emit_vector_compare is a bit
>> complicated to me, especially after we emit vector float
>> comparison insn with the given code directly. This patch is
>> to refine the handlings for vector integer comparison operators,
>> it becomes not recursive, and we don't need the helper function
>> rs6000_emit_vector_compare_inner any more.
>
> That sounds nice.
>
>> /* In vector.md, we support all kinds of vector float point
>> comparison operators in a comparison rtl pattern, we can
>> just emit the comparison rtx insn directly here. Besides,
>> we should have a centralized place to handle the possibility
>> - of raising invalid exception. */
>> - if (GET_MODE_CLASS (dmode) == MODE_VECTOR_FLOAT)
>> + of raising invalid exception. Also emit directly for vector
>> + integer comparison operators EQ/GT/GTU. */
>> + if (GET_MODE_CLASS (dmode) == MODE_VECTOR_FLOAT
>> + || rcode == EQ
>> + || rcode == GT
>> + || rcode == GTU)
>
> The comment still says it handles FP only. That would be best to keep
> imo: add a separate block of code to handle the integer stuff you want
> to add. You get the same or better generated code, the compiler is
> smart enough. Code is for the user to read, and C is not a portable
> assembler language.
OK, I'll make two blocks for FP and integer respectively. I struggled
a bit updating this hunk with comments for integer comparison
consideration, someone could argue that both can share the same handling
if updating the condition.
>
> This whole series needs to be factored better, it does way too many
> things, and only marginally related things, at every step. Or I don't
> see it anyway :-)
OK, I was thinking patch 1/2 is to unify the current vector float
comparison handlings, patch 2/2 is to refine the remaining handlings
for vector integer comparison. I'm pleased to factor it better, any
suggestions on concrete code is highly appreciated. :)
btw, I constructed one test case as below, there is no assembly change
before and after this patch.
#define GT(a, b) (((a) > (b)))
#define GE(a, b) (((a) >= (b)))
#define LT(a, b) (((a) < (b)))
#define LE(a, b) (((a) <= (b)))
#define EQ(a, b) (((a) == (b)))
#define NE(a, b) (((a) != (b)))
#define TEST_VECT(NAME, TYPE) \
__attribute__ ((noipa)) void test_##NAME##_##TYPE (TYPE *x, TYPE *y, \
int *res, int n) \
{ \
for (int i = 0; i < n; i++) \
res[i] = NAME (x[i], y[i]); \
}
#include "stdint.h"
#define TEST(TYPE) \
TEST_VECT (GT, TYPE) \
TEST_VECT (GE, TYPE) \
TEST_VECT (LT, TYPE) \
TEST_VECT (LE, TYPE) \
TEST_VECT (EQ, TYPE) \
TEST_VECT (NE, TYPE)
TEST (int64_t)
TEST (uint64_t)
TEST (int32_t)
TEST (uint32_t)
TEST (int16_t)
TEST (uint16_t)
TEST (int8_t)
TEST (uint8_t)
BR,
Kewen
next prev parent reply other threads:[~2022-11-17 7:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 6:48 [PATCH 1/2] rs6000: Emit vector fp comparison directly " Kewen.Lin
2022-11-16 6:51 ` [PATCH 2/2] rs6000: Refine integer comparison handlings " Kewen.Lin
2022-11-16 18:58 ` Segher Boessenkool
2022-11-17 7:52 ` Kewen.Lin [this message]
2022-11-18 15:18 ` Segher Boessenkool
2022-11-16 18:44 ` [PATCH 1/2] rs6000: Emit vector fp comparison directly " Segher Boessenkool
2022-11-17 6:59 ` Kewen.Lin
2022-11-18 15:10 ` Segher Boessenkool
2022-11-21 2:01 ` Kewen.Lin
2022-11-27 18:16 ` 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=e6035592-885c-1498-454e-411f83b01471@linux.ibm.com \
--to=linkw@linux.ibm.com \
--cc=bergner@linux.ibm.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=meissner@linux.ibm.com \
--cc=segher@kernel.crashing.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).