Error: $ g++ -c -O3 func.cpp func.cpp: In function ‘void g(bool)’: func.cpp:5:6: error: definition in block 61 does not dominate use in block 59 5 | void g(bool h) { | ^ for SSA_NAME: prephitmp_100 in statement: prephitmp_100 = PHI <prephitmp_100(59), _103(62)> PHI argument prephitmp_100 for PHI node prephitmp_100 = PHI <prephitmp_100(59), _103(62)> during GIMPLE pass: vect func.cpp:5:6: internal compiler error: verify_ssa failed 0x13368a2 verify_ssa(bool, bool) gcc/tree-ssa.c:1208 0x10228a5 execute_function_todo gcc/passes.c:1992 0x102357e execute_todo gcc/passes.c:2039 Reproducer: bool a; extern bool b[]; long c, d; int *f; void g(bool h) { for (short e = 0; e < c; e = 4) for (; d; d++) b[d] = a = f[d] ? c ? h : 0 : h; } GCC version: gcc version 11.0.0 (56638b9b1853666f575928f8baf17f70e4ed3517)
It might be related to bug 94443
Started with r9-5325-gf25507d041de4df6.
I'll have a look. There's a missed optimization but that causes the SSA update mechanism in the vectorizer to go out-of-sync somehow.
The bogus def is set via if (scalar_loop != loop) { /* If we copied from SCALAR_LOOP rather than LOOP, SSA_NAMEs from SCALAR_LOOP will have current_def set to SSA_NAMEs in the new_loop, but LOOP will not. slpeel_update_phi_nodes_for_guard{1,2} expects the LOOP SSA_NAMEs (on the exit edge and edge from latch to header) to have current_def set, so copy them over. */ slpeel_duplicate_current_defs_from_edges (single_exit (scalar_loop), exit); because that interferes with the renaming process. The if-conversion applied the missed optimization to the to-be vectorized loop introducing a LC PHI (required for the not if-converted copy) which has one invariant and one non-invariant arg. So we have to do that copying after renaming in the BBs. That seems to work, testing patch.
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:d0909f5858ad81e6d8b73fa6193be19cb5e6ed7b commit r11-1447-gd0909f5858ad81e6d8b73fa6193be19cb5e6ed7b Author: Richard Biener <rguenther@suse.de> Date: Wed Jun 17 14:57:59 2020 +0200 tree-optimization/95717 - fix SSA update for vectorizer epilogue This fixes yet another issue with the custom SSA updating in the vectorizer when we copy from the non-if-converted loop. We must not mess with current defs before we updated the BB copies. 2020-06-17 Richard Biener <rguenther@suse.de> PR tree-optimization/95717 * tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg): Move BB SSA updating before exit/latch PHI current def copying. * g++.dg/torture/pr95717.C: New testcase.
Fixed on trunk sofar.
The releases/gcc-10 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:f3a27a610b0eb9a7ea76f61b4fecf7e66e86a3e1 commit r10-8359-gf3a27a610b0eb9a7ea76f61b4fecf7e66e86a3e1 Author: Richard Biener <rguenther@suse.de> Date: Wed Jun 17 14:57:59 2020 +0200 tree-optimization/95717 - fix SSA update for vectorizer epilogue This fixes yet another issue with the custom SSA updating in the vectorizer when we copy from the non-if-converted loop. We must not mess with current defs before we updated the BB copies. 2020-06-17 Richard Biener <rguenther@suse.de> PR tree-optimization/95717 * tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg): Move BB SSA updating before exit/latch PHI current def copying. * g++.dg/torture/pr95717.C: New testcase. (cherry picked from commit d0909f5858ad81e6d8b73fa6193be19cb5e6ed7b)
The releases/gcc-9 branch has been updated by Richard Biener <rguenth@gcc.gnu.org>: https://gcc.gnu.org/g:1102a2c1fd221ee38f2f41aaf1094d4abbc3aedc commit r9-8861-g1102a2c1fd221ee38f2f41aaf1094d4abbc3aedc Author: Richard Biener <rguenther@suse.de> Date: Wed Jun 17 14:57:59 2020 +0200 tree-optimization/95717 - fix SSA update for vectorizer epilogue This fixes yet another issue with the custom SSA updating in the vectorizer when we copy from the non-if-converted loop. We must not mess with current defs before we updated the BB copies. 2020-06-17 Richard Biener <rguenther@suse.de> PR tree-optimization/95717 * tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg): Move BB SSA updating before exit/latch PHI current def copying. * g++.dg/torture/pr95717.C: New testcase. (cherry picked from commit d0909f5858ad81e6d8b73fa6193be19cb5e6ed7b)
Fixed.