public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Kewen Lin <linkw@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2182] rs6000: Support [u]mod<mode>3 for vector modulo insns Date: Fri, 9 Jul 2021 03:02:23 +0000 (GMT) [thread overview] Message-ID: <20210709030223.530D53AAB030@sourceware.org> (raw) https://gcc.gnu.org/g:062c762ef264dca89d01ebca2ef023ea91f31d50 commit r12-2182-g062c762ef264dca89d01ebca2ef023ea91f31d50 Author: Kewen Lin <linkw@linux.ibm.com> Date: Thu Jul 8 22:00:24 2021 -0500 rs6000: Support [u]mod<mode>3 for vector modulo insns This patch is to make Power10 newly introduced vector modulo instructions exploited in vectorized loops, it just simply renames existing define_insns as standard pattern names. gcc/ChangeLog: * config/rs6000/vsx.md (mods_<mode>): Rename to... (mod<mode>3): ... this. (modu_<mode>): Rename to... (umod<mode>3): ... this. * config/rs6000/rs6000-builtin.def (MODS_V2DI, MODS_V4SI, MODU_V2DI, MODU_V4SI): Adjust. gcc/testsuite/ChangeLog: * gcc.target/powerpc/mod-vectorize.c: New test. Diff: --- gcc/config/rs6000/rs6000-builtin.def | 8 ++--- gcc/config/rs6000/vsx.md | 4 +-- gcc/testsuite/gcc.target/powerpc/mod-vectorize.c | 46 ++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def index 6270444ef70..a0dfefccd43 100644 --- a/gcc/config/rs6000/rs6000-builtin.def +++ b/gcc/config/rs6000/rs6000-builtin.def @@ -3031,10 +3031,10 @@ BU_P10V_AV_2 (DIVS_V4SI, "vdivsw", CONST, divv4si3) BU_P10V_AV_2 (DIVS_V2DI, "vdivsd", CONST, divv2di3) BU_P10V_AV_2 (DIVU_V4SI, "vdivuw", CONST, udivv4si3) BU_P10V_AV_2 (DIVU_V2DI, "vdivud", CONST, udivv2di3) -BU_P10V_AV_2 (MODS_V2DI, "vmodsd", CONST, mods_v2di) -BU_P10V_AV_2 (MODS_V4SI, "vmodsw", CONST, mods_v4si) -BU_P10V_AV_2 (MODU_V2DI, "vmodud", CONST, modu_v2di) -BU_P10V_AV_2 (MODU_V4SI, "vmoduw", CONST, modu_v4si) +BU_P10V_AV_2 (MODS_V2DI, "vmodsd", CONST, modv2di3) +BU_P10V_AV_2 (MODS_V4SI, "vmodsw", CONST, modv4si3) +BU_P10V_AV_2 (MODU_V2DI, "vmodud", CONST, umodv2di3) +BU_P10V_AV_2 (MODU_V4SI, "vmoduw", CONST, umodv4si3) BU_P10V_AV_2 (MULHS_V2DI, "vmulhsd", CONST, mulhs_v2di) BU_P10V_AV_2 (MULHS_V4SI, "vmulhsw", CONST, mulhs_v4si) BU_P10V_AV_2 (MULHU_V2DI, "vmulhud", CONST, mulhu_v2di) diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index f2260badf70..f622873d758 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -6333,7 +6333,7 @@ [(set_attr "type" "vecdiv") (set_attr "size" "<bits>")]) -(define_insn "mods_<mode>" +(define_insn "mod<mode>3" [(set (match_operand:VIlong 0 "vsx_register_operand" "=v") (mod:VIlong (match_operand:VIlong 1 "vsx_register_operand" "v") (match_operand:VIlong 2 "vsx_register_operand" "v")))] @@ -6342,7 +6342,7 @@ [(set_attr "type" "vecdiv") (set_attr "size" "<bits>")]) -(define_insn "modu_<mode>" +(define_insn "umod<mode>3" [(set (match_operand:VIlong 0 "vsx_register_operand" "=v") (umod:VIlong (match_operand:VIlong 1 "vsx_register_operand" "v") (match_operand:VIlong 2 "vsx_register_operand" "v")))] diff --git a/gcc/testsuite/gcc.target/powerpc/mod-vectorize.c b/gcc/testsuite/gcc.target/powerpc/mod-vectorize.c new file mode 100644 index 00000000000..4d4f5cd6446 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/mod-vectorize.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-mdejagnu-cpu=power10 -O2 -ftree-vectorize -fno-vect-cost-model -fno-unroll-loops -fdump-tree-vect-details" } */ + +/* Test vectorizer can exploit ISA 3.1 instructions Vector Modulo + Signed/Unsigned Word/Doubleword for word/doubleword modulo operations. */ + +#define N 128 + +extern signed int si_a[N], si_b[N], si_c[N]; +extern unsigned int ui_a[N], ui_b[N], ui_c[N]; +extern signed long long sd_a[N], sd_b[N], sd_c[N]; +extern unsigned long long ud_a[N], ud_b[N], ud_c[N]; + +__attribute__ ((noipa)) void +test_si () +{ + for (int i = 0; i < N; i++) + si_c[i] = si_a[i] % si_b[i]; +} + +__attribute__ ((noipa)) void +test_ui () +{ + for (int i = 0; i < N; i++) + ui_c[i] = ui_a[i] % ui_b[i]; +} + +__attribute__ ((noipa)) void +test_sd () +{ + for (int i = 0; i < N; i++) + sd_c[i] = sd_a[i] % sd_b[i]; +} + +__attribute__ ((noipa)) void +test_ud () +{ + for (int i = 0; i < N; i++) + ud_c[i] = ud_a[i] % ud_b[i]; +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" } } */ +/* { dg-final { scan-assembler-times {\mvmodsw\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mvmoduw\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mvmodsd\M} 1 } } */ +/* { dg-final { scan-assembler-times {\mvmodud\M} 1 } } */
reply other threads:[~2021-07-09 3:02 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210709030223.530D53AAB030@sourceware.org \ --to=linkw@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).