[Bug tree-optimization/98516] [11 Regression] Wrong code generated by tree vectorizer since r11-3823-g126ed72b9f48f853
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98516 --- Comment #10 from rguenther at suse dot de --- On Tue, 5 Jan 2021, mar...@mpa-garching.mpg.de wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98516 > > --- Comment #9 from Martin Reinecke --- > Thanks, this fixes the reduced test case for me as well! > > Unfortunately there seems to be more where this one came from, since my > comprehensive test suite still fails ... I'll try to produce test cases and > open another bug report. Thanks, that's appreciated!
[Bug tree-optimization/98516] [11 Regression] Wrong code generated by tree vectorizer since r11-3823-g126ed72b9f48f853
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98516 --- Comment #9 from Martin Reinecke --- Thanks, this fixes the reduced test case for me as well! Unfortunately there seems to be more where this one came from, since my comprehensive test suite still fails ... I'll try to produce test cases and open another bug report.
[Bug tree-optimization/98516] [11 Regression] Wrong code generated by tree vectorizer since r11-3823-g126ed72b9f48f853
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98516 Richard Biener changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #8 from Richard Biener --- Fixed.
[Bug tree-optimization/98516] [11 Regression] Wrong code generated by tree vectorizer since r11-3823-g126ed72b9f48f853
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98516 --- Comment #7 from CVS Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:33a63257701c8d94ee375e32ff1837c989d8ded6 commit r11-6478-g33a63257701c8d94ee375e32ff1837c989d8ded6 Author: Richard Biener Date: Tue Jan 5 16:17:15 2021 +0100 tree-optimization/98516 - fix SLP permute opt materialization When materializing on a VEC_PERM node we have to permute the incoming vectors, not the outgoing one. 2021-01-05 Richard Biener PR tree-optimization/98516 * tree-vect-slp.c (vect_optimize_slp): Permute the incoming lanes when materializing on a VEC_PERM node. (vectorizable_slp_permutation): Dump the permute properly. * gcc.dg/vect/bb-slp-pr98516-1.c: New testcase. * gcc.dg/vect/bb-slp-pr98516-2.c: Likewise.
[Bug tree-optimization/98516] [11 Regression] Wrong code generated by tree vectorizer since r11-3823-g126ed72b9f48f853
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98516 --- Comment #6 from Richard Biener --- /* { dg-do run } */ double a[4], b[2]; void __attribute__((noipa)) foo () { double a0 = a[0]; double a1 = a[1]; double a2 = a[2]; double a3 = a[3]; b[0] = a1 - a3; b[1] = a0 + a2; } int main() { a[0] = 1.; a[1] = 2.; a[2] = 3.; a[3] = 4.; foo (); if (b[0] != -2 || b[1] != 4) __builtin_abort (); return 0; }
[Bug tree-optimization/98516] [11 Regression] Wrong code generated by tree vectorizer since r11-3823-g126ed72b9f48f853
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98516 --- Comment #5 from Richard Biener --- Meh, it's very hard to spot the actual problem :/ diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index d8a2ceb0fa1..dee360307d0 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -5058,8 +5059,7 @@ vect_slp_region (vec bbs, vec datarefs, bb_vinfo->shared->check_datarefs (); bb_vinfo->vector_mode = next_vector_mode; - if (vect_slp_analyze_bb_1 (bb_vinfo, n_stmts, fatal, dataref_groups) - && dbg_cnt (vect_slp)) + if (vect_slp_analyze_bb_1 (bb_vinfo, n_stmts, fatal, dataref_groups)) { if (dump_enabled_p ()) { @@ -5090,6 +5090,9 @@ vect_slp_region (vec bbs, vec datarefs, continue; } + if (!dbg_cnt (vect_slp)) + continue; + if (!vectorized && dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "Basic block will be vectorized " helps to narrow down the bogus vectorization, -fdbg-cnt=vect_slp:2:2 triggers it but the SLP region is quite big still. diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index d8a2ceb0fa1..dee360307d0 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3310,6 +3310,7 @@ vect_optimize_slp (vec_info *vinfo) auto_vec leafs; vect_slp_build_vertices (vinfo, vertices, leafs); +#if 0 struct graph *slpg = new_graph (vertices.length ()); FOR_EACH_VEC_ELT (vertices, i, node) { @@ -3619,7 +3620,7 @@ vect_optimize_slp (vec_info *vinfo) while (!perms.is_empty ()) perms.pop ().release (); free_graph (slpg); - +#endif /* Now elide load permutations that are not necessary. */ for (i = 0; i < leafs.length (); ++i) avoids the miscompilation. The key transform we're doing is eliding load permutations that swap real/imag parts and instead adjust the lane permutation of a blend created for plus/minus ops which is where the bug is I think. We're changing t.C:80:7: note: node 0x4204018 (max_nunits=2, refcnt=1) t.C:80:7: note: op: VEC_PERM_EXPR t.C:80:7: note: stmt 0 _37 = _35 - _36; t.C:80:7: note: stmt 1 _34 = _32 + _33; t.C:80:7: note: lane permutation { 0[0] 1[1] } t.C:80:7: note: children 0x42045f0 0x4204678 to t.C:80:7: note: node 0x4207018 (max_nunits=2, refcnt=1) t.C:80:7: note: op: VEC_PERM_EXPR t.C:80:7: note: stmt 0 _37 = _35 - _36; t.C:80:7: note: stmt 1 _34 = _32 + _33; t.C:80:7: note: lane permutation { 1[1] 0[0] } t.C:80:7: note: children 0x42075f0 0x4207678 but that's not what is necessary - we have permuted the lanes of the children but permuting the blend will not materialize properly instead we need to generate { 0[1] 1[0] } I think. I'm trying to create a simpler C testcase now.
[Bug tree-optimization/98516] [11 Regression] Wrong code generated by tree vectorizer since r11-3823-g126ed72b9f48f853
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98516 Richard Biener changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Priority|P3 |P1 Target Milestone|--- |11.0 --- Comment #4 from Richard Biener --- Mine.
[Bug tree-optimization/98516] [11 Regression] Wrong code generated by tree vectorizer since r11-3823-g126ed72b9f48f853
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98516 --- Comment #3 from Martin Liška --- Minimal options: g++ pr98516.c -std=c++17 -O1 -ftree-slp-vectorize -fno-signed-zeros -fdbg-cnt=vect_slp:2 while this one is fine: g++ pr98516.c -std=c++17 -O1 -ftree-slp-vectorize -fno-signed-zeros -fdbg-cnt=vect_slp:1
[Bug tree-optimization/98516] [11 Regression] Wrong code generated by tree vectorizer since r11-3823-g126ed72b9f48f853
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98516 Martin Liška changed: What|Removed |Added Ever confirmed|0 |1 Last reconfirmed||2021-01-05 Status|UNCONFIRMED |NEW Summary|Wrong code generated by |[11 Regression] Wrong code |tree vectorizer |generated by tree ||vectorizer since ||r11-3823-g126ed72b9f48f853 CC||marxin at gcc dot gnu.org, ||rguenth at gcc dot gnu.org --- Comment #2 from Martin Liška --- Thanks, started with r11-3823-g126ed72b9f48f853.