public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Robin Dapp <rdapp@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-9366] vect: Do not peel epilogue for partial vectors. Date: Thu, 7 Mar 2024 20:03:43 +0000 (GMT) [thread overview] Message-ID: <20240307200343.4C78E3858D35@sourceware.org> (raw) https://gcc.gnu.org/g:226043a4d8fb23c7fe7bf16e485b3cfaa094db21 commit r14-9366-g226043a4d8fb23c7fe7bf16e485b3cfaa094db21 Author: Robin Dapp <rdapp@ventanamicro.com> Date: Wed Mar 6 16:54:35 2024 +0100 vect: Do not peel epilogue for partial vectors. r14-7036-gcbf569486b2dec added an epilogue vectorization guard for early break but PR114196 shows that we also run into the problem without early break. Therefore merge the condition into the topmost vectorization guard. gcc/ChangeLog: PR middle-end/114196 * tree-vect-loop-manip.cc (vect_can_peel_nonlinear_iv_p): Merge vectorization guards. gcc/testsuite/ChangeLog: * gcc.target/aarch64/pr114196.c: New test. * gcc.target/riscv/rvv/autovec/pr114196.c: New test. Diff: --- gcc/testsuite/gcc.target/aarch64/pr114196.c | 19 ++++++++++++++ .../gcc.target/riscv/rvv/autovec/pr114196.c | 19 ++++++++++++++ gcc/tree-vect-loop-manip.cc | 30 +++++----------------- 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/gcc/testsuite/gcc.target/aarch64/pr114196.c b/gcc/testsuite/gcc.target/aarch64/pr114196.c new file mode 100644 index 00000000000..15e4b0e31b8 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr114196.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options { -O3 -fno-vect-cost-model -march=armv9-a -msve-vector-bits=256 } } */ + +unsigned a; +int b; +long *c; + +int +main () +{ + for (int d = 0; d < 22; d += 4) { + b = ({ + int e = c[d]; + e; + }) + ? 0 : -c[d]; + a *= 3; + } +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr114196.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr114196.c new file mode 100644 index 00000000000..7ba9cbbed70 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr114196.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options { -O3 -fno-vect-cost-model -march=rv64gcv_zvl256b -mabi=lp64d -mrvv-vector-bits=zvl } } */ + +unsigned a; +int b; +long *c; + +int +main () +{ + for (int d = 0; d < 22; d += 4) { + b = ({ + int e = c[d]; + e; + }) + ? 0 : -c[d]; + a *= 3; + } +} diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index f72da915103..56a6d8e4a8d 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -2129,16 +2129,19 @@ vect_can_peel_nonlinear_iv_p (loop_vec_info loop_vinfo, For mult, don't known how to generate init_expr * pow (step, niters) for variable niters. For neg, it should be ok, since niters of vectorized main loop - will always be multiple of 2. */ - if ((!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) - || !LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant ()) + will always be multiple of 2. + See also PR113163 and PR114196. */ + if ((!LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant () + || LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo) + || !LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)) && induction_type != vect_step_op_neg) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, "Peeling for epilogue is not supported" " for nonlinear induction except neg" - " when iteration count is unknown.\n"); + " when iteration count is unknown or" + " when using partial vectorization.\n"); return false; } @@ -2178,25 +2181,6 @@ vect_can_peel_nonlinear_iv_p (loop_vec_info loop_vinfo, return false; } - /* We can't support partial vectors and early breaks with an induction - type other than add or neg since we require the epilog and can't - perform the peeling. The below condition mirrors that of - vect_gen_vector_loop_niters where niters_vector_mult_vf_var then sets - step_vector to VF rather than 1. This is what creates the nonlinear - IV. PR113163. */ - if (LOOP_VINFO_EARLY_BREAKS (loop_vinfo) - && LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant () - && LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo) - && induction_type != vect_step_op_neg) - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "Peeling for epilogue is not supported" - " for nonlinear induction except neg" - " when VF is known and early breaks.\n"); - return false; - } - return true; }
reply other threads:[~2024-03-07 20:03 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=20240307200343.4C78E3858D35@sourceware.org \ --to=rdapp@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).