diff options
author | Richard Biener <rguenther@suse.de> | 2021-06-28 11:05:46 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-06-28 11:55:24 +0200 |
commit | f80c4eaca0805bc9e68ed944519519c3dd1c12e1 (patch) | |
tree | fe862ede354692a749f1bc85bdef264d22572217 /gcc | |
parent | ad26c076aaa6f9af144c33c9c04c5dc8010ad156 (diff) | |
download | gcc-f80c4eaca0805bc9e68ed944519519c3dd1c12e1.zip gcc-f80c4eaca0805bc9e68ed944519519c3dd1c12e1.tar.gz gcc-f80c4eaca0805bc9e68ed944519519c3dd1c12e1.tar.bz2 |
tree-optimization/101229 - fix vectorizer SLP hybrid detection with PHIs
This fixes the missing handling of PHIs in gimple_walk_op which causes
the new vectorizer SLP hybrid detection scheme to fail.
2021-06-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/101229
* gimple-walk.c (gimple_walk_op): Handle PHIs.
* gcc.dg/torture/pr101229.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/gimple-walk.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr101229.c | 19 |
2 files changed, 43 insertions, 0 deletions
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c index e4a55f1..18884c4 100644 --- a/gcc/gimple-walk.c +++ b/gcc/gimple-walk.c @@ -517,6 +517,30 @@ walk_gimple_op (gimple *stmt, walk_tree_fn callback_op, case GIMPLE_PREDICT: break; + case GIMPLE_PHI: + /* PHIs are not GSS_WITH_OPS so we need to handle them explicitely. */ + { + gphi *phi = as_a <gphi *> (stmt); + if (wi) + { + wi->val_only = true; + wi->is_lhs = true; + } + ret = walk_tree (gimple_phi_result_ptr (phi), callback_op, wi, pset); + if (wi) + wi->is_lhs = false; + if (ret) + return ret; + for (unsigned i = 0; i < gimple_phi_num_args (phi); ++i) + { + ret = walk_tree (gimple_phi_arg_def_ptr (phi, i), + callback_op, wi, pset); + if (ret) + return ret; + } + break; + } + default: { enum gimple_statement_structure_enum gss; diff --git a/gcc/testsuite/gcc.dg/torture/pr101229.c b/gcc/testsuite/gcc.dg/torture/pr101229.c new file mode 100644 index 0000000..3708031 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr101229.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ + +int a[1024]; +void foo() +{ + for (int i; i; i += 4) { + int suma = a[i]; + int sumb = a[i + 1]; + int sumc; + for (unsigned j = 0; j < 77; ++j) { + suma = (suma ^ i) + 1; + sumb = (sumb ^ i) + 2; + sumc = suma ^ i; + } + a[i] = suma; + a[i + 1] = sumb; + a[i + 2] = sumc; + } +} |