public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1115] tree-optimization/100778 - avoid cross-BB vectorization of trapping op Date: Fri, 28 May 2021 13:18:36 +0000 (GMT) [thread overview] Message-ID: <20210528131836.070F1383D03B@sourceware.org> (raw) https://gcc.gnu.org/g:f7a07f5a5d8065e7f11133dd1f4ad3510ab2195b commit r12-1115-gf7a07f5a5d8065e7f11133dd1f4ad3510ab2195b Author: Richard Biener <rguenther@suse.de> Date: Fri May 28 14:26:06 2021 +0200 tree-optimization/100778 - avoid cross-BB vectorization of trapping op This avoids vectorizing a possibly trapping operation when lanes are handled in different BBs. I spotted this when working on the originally reported issue in PR100778. 2021-05-28 Richard Biener <rguenther@suse.de> PR tree-optimization/100778 * tree-vect-slp.c (vect_build_slp_tree_1): Prevent possibly trapping ops in different BBs. * gcc.dg/vect/bb-slp-pr100778-1.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/vect/bb-slp-pr100778-1.c | 18 ++++++++++++++++++ gcc/tree-vect-slp.c | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr100778-1.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr100778-1.c new file mode 100644 index 00000000000..9f8b7eecef1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr100778-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_double } */ + +double foo (int x, double *p) +{ + double res = p[0] + p[1]; + double tem = p[0] / x; + if (x) + { + p[0] = tem; + p[1] /= x; + } + return res + tem; +} + +/* We may not SLP vectorize the FP division because it can trap and it + is distributed between two basic-blocks. */ +/* { dg-final { scan-tree-dump "Build SLP failed: different BB for PHI or possibly trapping operation in _\[0-9\]+ = _\[0-9\]+ / _\[0-9\]+;" "slp2" } } */ diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 0ec92b0f0ca..ca1539e63f2 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -1214,14 +1214,14 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, } } - if (phi_p + if ((phi_p || gimple_could_trap_p (stmt_info->stmt)) && (gimple_bb (first_stmt_info->stmt) != gimple_bb (stmt_info->stmt))) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, "Build SLP failed: different BB for PHI " - "in %G", stmt); + "or possibly trapping operation in %G", stmt); /* Mismatch. */ continue; }
reply other threads:[~2021-05-28 13:18 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=20210528131836.070F1383D03B@sourceware.org \ --to=rguenth@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).