Created attachment 40978 [details] Reproducer. ICE with -O3 -march=broadwell (and skylake-avx512). Everything works fine with other optimization levels. Error: >$ g++ -O3 -march=broadwell -c repr.cpp repr.cpp: In function ‘void foo()’: repr.cpp:17:6: error: definition in block 7 does not dominate use in block 6 void foo() { ^~~ for SSA_NAME: _133 in statement: slsr_142 = PHI <_133(6), _133(16)> PHI argument _133 for PHI node slsr_142 = PHI <_133(6), _133(16)> repr.cpp:17:6: internal compiler error: verify_ssa failed 0xf84ad3 verify_ssa(bool, bool) /home/vsevolod/workspace/gcc-dev/trunk/gcc/tree-ssa.c:1184 0xc98ea7 execute_function_todo /home/vsevolod/workspace/gcc-dev/trunk/gcc/passes.c:1973 0xc99e0b execute_todo /home/vsevolod/workspace/gcc-dev/trunk/gcc/passes.c:2016 Reproducer: extern short var_2; extern short var_4; extern const bool var_32; extern short var_36; extern const bool var_37; extern bool var_46; extern unsigned int var_47; extern short var_49; extern unsigned int var_56; extern unsigned int var_62; extern unsigned int var_65; extern bool var_831; extern unsigned int var_843; extern short var_846; extern short var_889; void foo() { if (var_36 * var_37) var_831 = var_56 = 0; else var_65 = 0; if (var_46) var_843 = 0; var_846 = 0; if ((var_4 == 0) >> (var_32 | -(var_37 < var_46 || var_36)) + 8) var_49 = 2032651381 * bool(var_2 * var_37); else { var_62 = 0; var_47 = (var_46 || var_36) * (var_2 * var_37); } var_889 = bool(var_2 * var_37); } GCC version: gcc version 7.0.1 (today's trunk)
Confirmed. SLSR is at fault.
OK, I'll have a look.
Reproducible on ppc64le without any -march.
PRE creates a situation where a conditional SLSR candidate depends on a PHI that occurs prior to the basis for the candidate. SLSR doesn't notice this and eventually creates a phi basis that is not dominated by the true basis, leading to a use of an undefined variable. The fix will be to test whether the basis dominates all PHIs and their PHI argument definitions, and avoid the optimization in such cases. Testing now.
Author: wschmidt Date: Mon Mar 20 20:04:25 2017 New Revision: 246290 URL: https://gcc.gnu.org/viewcvs?rev=246290&root=gcc&view=rev Log: [gcc] 2017-03-20 Bill Schmidt <wschmidt@linux.vnet.ibm.com> PR tree-optimization/80054 * gimple-ssa-strength-reduction.c (all_phi_incrs_profitable): Fail the optimization if a PHI or any of its arguments is not dominated by the candidate's basis. Use gphi* rather than gimple* as appropriate. (replace_profitable_candidates): Clean up a gimple* variable that should be a gphi* variable. [gcc/testsuite] 2017-03-20 Bill Schmidt <wschmidt@linux.vnet.ibm.com> PR tree-optimization/80054 * g++.dg/torture/pr80054.C: New file. Added: trunk/gcc/testsuite/g++.dg/torture/pr80054.C Modified: trunk/gcc/ChangeLog trunk/gcc/gimple-ssa-strength-reduction.c trunk/gcc/testsuite/ChangeLog
Fixed.