From: "Kewen.Lin" <linkw@linux.ibm.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
Jakub Jelinek <jakub@redhat.com>,
Richard Biener <richard.guenther@gmail.com>,
richard.sandiford@arm.com,
Bill Schmidt <wschmidt@linux.ibm.com>
Subject: Re: [PATCH V5, rs6000] Support vrotr<mode>3 for int vector types
Date: Mon, 05 Aug 2019 03:41:00 -0000 [thread overview]
Message-ID: <e9a8dd1d-f764-652e-2ae1-3956abb6ab49@linux.ibm.com> (raw)
In-Reply-To: <20190803205221.GE31406@gate.crashing.org>
[-- Attachment #1: Type: text/plain, Size: 2147 bytes --]
Hi Segher,
on 2019/8/4 脡脧脦莽4:52, Segher Boessenkool wrote:
> Hi!
>
> I somehow lost track of this email, sorry.
>
> On Fri, Aug 02, 2019 at 04:59:44PM +0800, Kewen.Lin wrote:
>> As to the predicate name and usage, I checked the current vector shifts,
>> they don't need to check const_vector specially (like right to left
>> conversion), excepting for the one "vec_shr_<mode>", but it checks for
>> scalar const int.
>
> I don't understand why we want to expand rotate-by-vector-of-immediates
> if we have no insns for that? If you just use vint_operand, what happens
> then?
>
You are right, if we just use vint_operand, the functionality should be the
same, the only small difference is the adjusted constant rotation number
isn't masked, but it would be fine for functionality.
One example for ULL >r 8, with const vector handling, it gets
xxspltib 33,56
Without the handling, it gets
xxsplitb 33,248
But I agree that it's trivial and unified it as below attached patch.
>> +/* { dg-options "-O3" } */
>> +/* { dg-require-effective-target powerpc_altivec_ok } */
>
> If you use altivec_ok, you need to use -maltivec in the options, too.
> This test should probably work with -O2 as well; use that, if possible.
>
Sorry, the test case depends on vectorization which isn't enabled at -O2
by default.
>> +/* { dg-require-effective-target powerpc_p8vector_ok } */
>
> I don't think we need this anymore? Not sure.
>
I thought -mdejagnu-cpu=power8 can only ensure power8 cpu setting takes
preference, but can't guarantee the current driver supports power8
complication. As your comments, I guess since gcc configuration don't
have without-cpu= etc., the power8 support should be always guaranteed?
Thanks,
Kewen
-----------------
gcc/ChangeLog
2019-08-05 Kewen Lin <linkw@gcc.gnu.org>
* config/rs6000/vector.md (vrotr<mode>3): New define_expand.
gcc/testsuite/ChangeLog
2019-08-05 Kewen Lin <linkw@gcc.gnu.org>
* gcc.target/powerpc/vec_rotate-1.c: New test.
* gcc.target/powerpc/vec_rotate-2.c: New test.
* gcc.target/powerpc/vec_rotate-3.c: New test.
* gcc.target/powerpc/vec_rotate-4.c: New test.
[-- Attachment #2: expand_v6.diff --]
[-- Type: text/plain, Size: 5092 bytes --]
diff --git a/gcc/config/rs6000/vector.md b/gcc/config/rs6000/vector.md
index 70bcfe02e22..886cbad1655 100644
--- a/gcc/config/rs6000/vector.md
+++ b/gcc/config/rs6000/vector.md
@@ -1260,6 +1260,19 @@
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
"")
+;; Expanders for rotatert to make use of vrotl
+(define_expand "vrotr<mode>3"
+ [(set (match_operand:VEC_I 0 "vint_operand")
+ (rotatert:VEC_I (match_operand:VEC_I 1 "vint_operand")
+ (match_operand:VEC_I 2 "vint_operand")))]
+ "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
+{
+ rtx rot_count = gen_reg_rtx (<MODE>mode);
+ emit_insn (gen_neg<mode>2 (rot_count, operands[2]));
+ emit_insn (gen_vrotl<mode>3 (operands[0], operands[1], rot_count));
+ DONE;
+})
+
;; Expanders for arithmetic shift left on each vector element
(define_expand "vashl<mode>3"
[(set (match_operand:VEC_I 0 "vint_operand")
diff --git a/gcc/testsuite/gcc.target/powerpc/vec_rotate-1.c b/gcc/testsuite/gcc.target/powerpc/vec_rotate-1.c
new file mode 100644
index 00000000000..f035a578292
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vec_rotate-1.c
@@ -0,0 +1,39 @@
+/* { dg-options "-O3" } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+
+/* Check vectorizer can exploit vector rotation instructions on Power, mainly
+ for the case rotation count is const number.
+
+ Check for instructions vrlb/vrlh/vrlw only available if altivec supported. */
+
+#define N 256
+unsigned int suw[N], ruw[N];
+unsigned short suh[N], ruh[N];
+unsigned char sub[N], rub[N];
+
+void
+testUW ()
+{
+ for (int i = 0; i < 256; ++i)
+ ruw[i] = (suw[i] >> 8) | (suw[i] << (sizeof (suw[0]) * 8 - 8));
+}
+
+void
+testUH ()
+{
+ for (int i = 0; i < 256; ++i)
+ ruh[i] = (unsigned short) (suh[i] >> 9)
+ | (unsigned short) (suh[i] << (sizeof (suh[0]) * 8 - 9));
+}
+
+void
+testUB ()
+{
+ for (int i = 0; i < 256; ++i)
+ rub[i] = (unsigned char) (sub[i] >> 5)
+ | (unsigned char) (sub[i] << (sizeof (sub[0]) * 8 - 5));
+}
+
+/* { dg-final { scan-assembler {\mvrlw\M} } } */
+/* { dg-final { scan-assembler {\mvrlh\M} } } */
+/* { dg-final { scan-assembler {\mvrlb\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/vec_rotate-2.c b/gcc/testsuite/gcc.target/powerpc/vec_rotate-2.c
new file mode 100644
index 00000000000..0a2a965ddcb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vec_rotate-2.c
@@ -0,0 +1,19 @@
+/* { dg-require-effective-target powerpc_p8vector_ok } */
+/* { dg-options "-O3 -mdejagnu-cpu=power8" } */
+
+/* Check vectorizer can exploit vector rotation instructions on Power8, mainly
+ for the case rotation count is const number.
+
+ Check for vrld which is available on Power8 and above. */
+
+#define N 256
+unsigned long long sud[N], rud[N];
+
+void
+testULL ()
+{
+ for (int i = 0; i < 256; ++i)
+ rud[i] = (sud[i] >> 8) | (sud[i] << (sizeof (sud[0]) * 8 - 8));
+}
+
+/* { dg-final { scan-assembler {\mvrld\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/vec_rotate-3.c b/gcc/testsuite/gcc.target/powerpc/vec_rotate-3.c
new file mode 100644
index 00000000000..5e90ae6fd63
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vec_rotate-3.c
@@ -0,0 +1,40 @@
+/* { dg-options "-O3" } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+
+/* Check vectorizer can exploit vector rotation instructions on Power, mainly
+ for the case rotation count isn't const number.
+
+ Check for instructions vrlb/vrlh/vrlw only available if altivec supported. */
+
+#define N 256
+unsigned int suw[N], ruw[N];
+unsigned short suh[N], ruh[N];
+unsigned char sub[N], rub[N];
+extern unsigned char rot_cnt;
+
+void
+testUW ()
+{
+ for (int i = 0; i < 256; ++i)
+ ruw[i] = (suw[i] >> rot_cnt) | (suw[i] << (sizeof (suw[0]) * 8 - rot_cnt));
+}
+
+void
+testUH ()
+{
+ for (int i = 0; i < 256; ++i)
+ ruh[i] = (unsigned short) (suh[i] >> rot_cnt)
+ | (unsigned short) (suh[i] << (sizeof (suh[0]) * 8 - rot_cnt));
+}
+
+void
+testUB ()
+{
+ for (int i = 0; i < 256; ++i)
+ rub[i] = (unsigned char) (sub[i] >> rot_cnt)
+ | (unsigned char) (sub[i] << (sizeof (sub[0]) * 8 - rot_cnt));
+}
+
+/* { dg-final { scan-assembler {\mvrlw\M} } } */
+/* { dg-final { scan-assembler {\mvrlh\M} } } */
+/* { dg-final { scan-assembler {\mvrlb\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/vec_rotate-4.c b/gcc/testsuite/gcc.target/powerpc/vec_rotate-4.c
new file mode 100644
index 00000000000..0d3e8378ed6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vec_rotate-4.c
@@ -0,0 +1,20 @@
+/* { dg-require-effective-target powerpc_p8vector_ok } */
+/* { dg-options "-O3 -mdejagnu-cpu=power8" } */
+
+/* Check vectorizer can exploit vector rotation instructions on Power8, mainly
+ for the case rotation count isn't const number.
+
+ Check for vrld which is available on Power8 and above. */
+
+#define N 256
+unsigned long long sud[N], rud[N];
+extern unsigned char rot_cnt;
+
+void
+testULL ()
+{
+ for (int i = 0; i < 256; ++i)
+ rud[i] = (sud[i] >> rot_cnt) | (sud[i] << (sizeof (sud[0]) * 8 - rot_cnt));
+}
+
+/* { dg-final { scan-assembler {\mvrld\M} } } */
next prev parent reply other threads:[~2019-08-05 3:41 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-15 8:59 Check rrotate optab first when transforming lrotate Kewen.Lin
2019-07-15 9:16 ` Jakub Jelinek
2019-07-15 9:19 ` Richard Biener
2019-07-15 9:20 ` Richard Sandiford
2019-07-15 10:54 ` Kewen.Lin
2019-07-15 14:51 ` Segher Boessenkool
[not found] ` <d2ccc831-c805-c7b8-5a90-cb3e5ee5ed8b@linux.ibm.com>
2019-07-16 8:48 ` [RFC] Consider lrotate const rotation in vectorizer Kewen.Lin
2019-07-17 8:42 ` [PATCH, rs6000] Support vrotr<mode>3 for int vector types Kewen.Lin
2019-07-17 8:44 ` Jakub Jelinek
2019-07-17 9:38 ` Kewen.Lin
2019-07-17 10:18 ` Jakub Jelinek
2019-07-17 13:48 ` Segher Boessenkool
2019-07-18 6:06 ` Kewen.Lin
2019-07-18 20:06 ` Segher Boessenkool
2019-07-19 6:51 ` Kewen.Lin
2019-07-19 15:49 ` Segher Boessenkool
2019-07-23 7:32 ` [PATCH V2, " Kewen.Lin
2019-07-25 14:24 ` Segher Boessenkool
2019-07-26 3:33 ` [PATCH V3, " Kewen.Lin
2019-07-26 3:37 ` [PATCH V4, " Kewen.Lin
2019-07-26 14:28 ` [PATCH V3, " Segher Boessenkool
2019-08-02 8:59 ` [PATCH V5, " Kewen.Lin
2019-08-03 20:52 ` Segher Boessenkool
2019-08-05 3:41 ` Kewen.Lin [this message]
2019-08-05 21:50 ` Segher Boessenkool
2019-08-06 3:11 ` Kewen.Lin
2019-08-06 15:12 ` Segher Boessenkool
2019-07-17 10:39 ` [RFC] Consider lrotate const rotation in vectorizer Richard Biener
2019-07-17 11:19 ` Jakub Jelinek
2019-07-17 11:35 ` Richard Biener
2019-07-17 11:56 ` Richard Biener
2019-07-17 13:58 ` Segher Boessenkool
2019-07-17 17:51 ` Segher Boessenkool
2019-07-18 7:03 ` Jakub Jelinek
2019-07-18 19:45 ` Segher Boessenkool
2019-07-18 15:17 ` Richard Earnshaw (lists)
2019-07-18 15:26 ` Jakub Jelinek
2019-07-18 15:31 ` Richard Earnshaw (lists)
2019-07-18 15:35 ` Jakub Jelinek
2019-07-18 15:44 ` Richard Earnshaw (lists)
2019-07-18 18:04 ` Segher Boessenkool
2019-07-18 6:28 ` Kewen.Lin
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=e9a8dd1d-f764-652e-2ae1-3956abb6ab49@linux.ibm.com \
--to=linkw@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=richard.guenther@gmail.com \
--cc=richard.sandiford@arm.com \
--cc=segher@kernel.crashing.org \
--cc=wschmidt@linux.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).