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 r14-4303] tree-optimization/111614 - missing convert in undistribute_bitref_for_vector Date: Thu, 28 Sep 2023 09:25:24 +0000 (GMT) [thread overview] Message-ID: <20230928092524.F325B3861897@sourceware.org> (raw) https://gcc.gnu.org/g:88d79b9b03eccf39921d13c2cbd1acc50aeda126 commit r14-4303-g88d79b9b03eccf39921d13c2cbd1acc50aeda126 Author: Richard Biener <rguenther@suse.de> Date: Thu Sep 28 09:41:30 2023 +0200 tree-optimization/111614 - missing convert in undistribute_bitref_for_vector The following adjusts a flawed guard for converting the first vector of the sum we create in undistribute_bitref_for_vector. PR tree-optimization/111614 * tree-ssa-reassoc.cc (undistribute_bitref_for_vector): Properly convert the first vector when required. * gcc.dg/torture/pr111614.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/torture/pr111614.c | 23 +++++++++++++++++++++++ gcc/tree-ssa-reassoc.cc | 27 +++++++++++++++------------ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/gcc/testsuite/gcc.dg/torture/pr111614.c b/gcc/testsuite/gcc.dg/torture/pr111614.c new file mode 100644 index 00000000000..0f3ecbae86c --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr111614.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +int a, b, c, d, e; +static void f() { + int *g = &b; + b = 1; + for (; b >= 0; b--) { + c = 0; + for (; c <= 1; c++) + e = 0; + for (; e <= 1; e++) { + int h, i = h = 13; + for (; h; h--) + i = i << a; + d &= i + c + 9 + *g; + } + } +} +int main() { + f(); + for (;;) + ; +} diff --git a/gcc/tree-ssa-reassoc.cc b/gcc/tree-ssa-reassoc.cc index eda03bf98a6..41ee36413b5 100644 --- a/gcc/tree-ssa-reassoc.cc +++ b/gcc/tree-ssa-reassoc.cc @@ -2102,12 +2102,24 @@ undistribute_bitref_for_vector (enum tree_code opcode, { sum = build_and_add_sum (vec_type, sum_vec, valid_vecs[i + 1], opcode); + /* Update the operands only after build_and_add_sum, + so that we don't have to repeat the placement algorithm + of build_and_add_sum. */ + if (sum_vec == tvec + && !useless_type_conversion_p (vec_type, TREE_TYPE (sum_vec))) + { + gimple_stmt_iterator gsi = gsi_for_stmt (sum); + tree vce = build1 (VIEW_CONVERT_EXPR, vec_type, sum_vec); + tree lhs = make_ssa_name (vec_type); + gimple *g = gimple_build_assign (lhs, VIEW_CONVERT_EXPR, vce); + gimple_set_uid (g, gimple_uid (sum)); + gsi_insert_before (&gsi, g, GSI_NEW_STMT); + gimple_assign_set_rhs1 (sum, lhs); + update_stmt (sum); + } if (!useless_type_conversion_p (vec_type, TREE_TYPE (valid_vecs[i + 1]))) { - /* Update the operands only after build_and_add_sum, - so that we don't have to repeat the placement algorithm - of build_and_add_sum. */ gimple_stmt_iterator gsi = gsi_for_stmt (sum); tree vce = build1 (VIEW_CONVERT_EXPR, vec_type, valid_vecs[i + 1]); @@ -2116,15 +2128,6 @@ undistribute_bitref_for_vector (enum tree_code opcode, gimple_set_uid (g, gimple_uid (sum)); gsi_insert_before (&gsi, g, GSI_NEW_STMT); gimple_assign_set_rhs2 (sum, lhs); - if (sum_vec == tvec) - { - vce = build1 (VIEW_CONVERT_EXPR, vec_type, sum_vec); - lhs = make_ssa_name (vec_type); - g = gimple_build_assign (lhs, VIEW_CONVERT_EXPR, vce); - gimple_set_uid (g, gimple_uid (sum)); - gsi_insert_before (&gsi, g, GSI_NEW_STMT); - gimple_assign_set_rhs1 (sum, lhs); - } update_stmt (sum); } sum_vec = gimple_get_lhs (sum);
reply other threads:[~2023-09-28 9:25 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=20230928092524.F325B3861897@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).