[Bug tree-optimization/104551] New: Wrong code with -O3 for skylake-avx512, icelake-server, and sapphirerapids

2022-02-15 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104551

Bug ID: 104551
   Summary: Wrong code with -O3 for skylake-avx512,
icelake-server, and sapphirerapids
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Reproducer (I was not able to merge it into a single file):
// func.cpp
extern unsigned var_11, var_178;
extern unsigned char arr_492[];
void test() {
  for (bool a = 0; a < (bool)var_11; a = 2)
for (unsigned b = 0; b < var_11;
 b += 1)
  var_178 = arr_492[b] ? arr_492[b] : (char) b;
}

// driver.cpp 
unsigned int var_11 = 16U;
unsigned int var_178 = 0;
unsigned char arr_492 [16];

void test();

int main() {
for (int i = 0; i < 16; ++i)
arr_492 [i] = (unsigned char)128;
test();
__builtin_printf("%u\n", var_178);
if (var_178 != 128)
__builtin_abort();
return 0;
}

Error:
>$ g++ -O0 func.cpp driver.cpp -march=skylake-avx512 && sde -skx -- ./a.out 
128
>$ g++ -O3 func.cpp driver.cpp -march=skylake-avx512 && sde -skx -- ./a.out 
4294967168
Aborted (core dumped)

g++ (git://gcc.gnu.org/git/gcc.git:master
58aeb75d4097010ad9bb72b964265b18ab284f93) 12.0.1 20220213 (experimental)

[Bug tree-optimization/103800] New: ICE in vectorizable_phi, at tree-vect-loop.c:7861 with -O3 -march=skylake-avx512

2021-12-22 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103800

Bug ID: 103800
   Summary: ICE in vectorizable_phi, at tree-vect-loop.c:7861 with
-O3 -march=skylake-avx512
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Link to the Compiler Explorer: https://godbolt.org/z/bWdof9c8s
Reproducer:
int a;
long b;
extern int c[], d[];
extern bool e[];
void f() {
  if (a)
;
  for (;;) {
for (int g = 2; g; g = a)
  d[g] = 0;
for (int h = 1; h < 13; h++)
  e[h] = b ? (short)c[4 + h - 1] : c[4 + h - 1];
  }
}


Error:
>$ g++ -O3 -march=skylake-avx512 -c func.cpp
during GIMPLE pass: slp
func.cpp: In function 'void f()':
func.cpp:5:6: internal compiler error: in vectorizable_phi, at
tree-vect-loop.c:7861
5 | void f() {
  |  ^
0x8bca05 vectorizable_phi(vec_info*, _stmt_vec_info*, gimple**, _slp_tree*,
vec*)
/testing/gcc/gcc_src_master/gcc/tree-vect-loop.c:7861
0x20abd84 vect_analyze_stmt(vec_info*, _stmt_vec_info*, bool*, _slp_tree*,
_slp_instance*, vec*)
/testing/gcc/gcc_src_master/gcc/tree-vect-stmts.c:11125
0x14a2186 vect_slp_analyze_node_operations_1
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:4481
0x14a2186 vect_slp_analyze_node_operations
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:4640
0x14a2097 vect_slp_analyze_node_operations
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:4620
0x14a2097 vect_slp_analyze_node_operations
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:4620
0x14a2097 vect_slp_analyze_node_operations
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:4620
0x14a4811 vect_slp_analyze_operations(vec_info*)
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:4879
0x14a9605 vect_slp_analyze_bb_1
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:5817
0x14a9605 vect_slp_region
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:5864
0x14aae33 vect_slp_bbs
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:6056
0x14ab22c vect_slp_function(function*)
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:6144
0x14b1c82 execute
/testing/gcc/gcc_src_master/gcc/tree-vectorizer.c:1503
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

GCC version:
gcc version 12.0.0 20211219 (fcbf94a5be9e0c1ecad92da773a6632b86b7f70a) (GCC)

[Bug tree-optimization/103517] New: ICE in as_a, at is-a.h:242 with -O2 -march=skylake-avx512

2021-12-01 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103517

Bug ID: 103517
   Summary: ICE in as_a, at is-a.h:242 with -O2
-march=skylake-avx512
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

The same error exists for Sapphire Rapids

Reproducer:
int a;
short b, c;
extern short d[];
void e() {
  for (short f = 1; f < (short)a; f += 2)
if (d[f + 1]) {
  b = d[f];
  c = d[f + 1];
}
}

Error:
>$ g++ -O2 -march=skylake-avx512 -c func.cpp
during GIMPLE pass: vect
func.cpp: In function 'void e()':
func.cpp:4:6: internal compiler error: in as_a, at is-a.h:242
4 | void e() {
  |  ^
0x8bc06a gphi const* as_a(gimple const*)
/testing/gcc/gcc_src_master/gcc/is-a.h:242
0x8bc684 gcall* as_a(gimple*)
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:991
0x8bc684 vect_build_slp_tree_1
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1155
0x14880cc vect_build_slp_tree_2
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1711
0x1487a0c vect_build_slp_tree
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1544
0x144 vect_build_slp_tree_2
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:2206
0x1487a0c vect_build_slp_tree
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1544
0x148c230 vect_build_slp_instance
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3019
0x148d6b5 vect_analyze_slp_instance
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3339
0x14920d4 vect_analyze_slp(vec_info*, unsigned int)
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3422
0x146d24a vect_analyze_loop_2
/testing/gcc/gcc_src_master/gcc/tree-vect-loop.c:2331
0x146eef9 vect_analyze_loop_1
/testing/gcc/gcc_src_master/gcc/tree-vect-loop.c:2830
0x146f40a vect_analyze_loop(loop*, vec_info_shared*)
/testing/gcc/gcc_src_master/gcc/tree-vect-loop.c:2952
0x14a3359 try_vectorize_loop_1
/testing/gcc/gcc_src_master/gcc/tree-vectorizer.c:1047
0x14a3359 try_vectorize_loop
/testing/gcc/gcc_src_master/gcc/tree-vectorizer.c:1162
0x14a3fb4 execute
/testing/gcc/gcc_src_master/gcc/tree-vectorizer.c:1278

gcc version 12.0.0 20211130 (6b8ecbc6d6652d061d7c72c64352d51eca2df6ca) (GCC)

[Bug tree-optimization/103489] New: ICE with -O3 in operator[], at vec.h:889

2021-11-30 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103489

Bug ID: 103489
   Summary: ICE with -O3 in operator[], at vec.h:889
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

The same reproducer also triggers ICE for Sapphire Rapids with a different
stack trace.

Link to the Compiler Explorer: https://godbolt.org/z/nxqPhnnoe

Reproducer:
bool a[80];
short b, f;
void g(short h[][8][16]) {
  for (bool c = 0; c < b;)
for (bool d = 0; d < (bool)f; d = 1)
  for (short e = 0; e < 16; e++)
a[e] = h[b][1][e];
}

Error:
>$ g++ -O3 -c func.cpp
during GIMPLE pass: slp
func.cpp: In function 'void g(short int (*)[8][16])':
func.cpp:3:6: internal compiler error: in operator[], at vec.h:889
3 | void g(short h[][8][16]) {
  |  ^
0x8b7e0a vec::operator[](unsigned int)
/testing/gcc/gcc_src_master/gcc/vec.h:889
0x8b896f vec::operator[](unsigned int)
/testing/gcc/gcc_src_master/gcc/tree-vect-loop.c:7877
0x8b896f vec::operator[](unsigned int)
/testing/gcc/gcc_src_master/gcc/vec.h:1495
0x8b896f vectorizable_phi(vec_info*, _stmt_vec_info*, gimple**, _slp_tree*,
vec*)
/testing/gcc/gcc_src_master/gcc/tree-vect-loop.c:7869
0x2093485 vect_transform_stmt(vec_info*, _stmt_vec_info*,
gimple_stmt_iterator*, _slp_tree*, _slp_instance*)
/testing/gcc/gcc_src_master/gcc/tree-vect-stmts.c:11174
0x1485797 vect_schedule_slp_node
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:7252
0x1496756 vect_schedule_scc
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:7450
0x14964e9 vect_schedule_scc
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:7431
0x14964e9 vect_schedule_scc
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:7431
0x1496daf vect_schedule_slp(vec_info*, vec<_slp_instance*, va_heap, vl_ptr>
const&)
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:7567
0x1498573 vect_slp_region
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:5926
0x1499503 vect_slp_bbs
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:6038
0x14998fc vect_slp_function(function*)
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:6126
0x14a02f2 execute
/testing/gcc/gcc_src_master/gcc/tree-vectorizer.c:1503

Sapphire Rapids Error:
>$ g++ -O3 -c func.cpp -march=sapphirerapids
func.cpp: In function 'void g(short int (*)[8][16])':
func.cpp:3:6: error: incompatible types in 'PHI' argument 1
3 | void g(short h[][8][16]) {
  |  ^
vector(16) unsigned char

vector(16) 

vect_a_I_lsm.30_92 = PHI <_97(2), mask__28.29_93(4)>
during GIMPLE pass: slp
func.cpp:3:6: internal compiler error: verify_gimple failed
0x123e31a verify_gimple_in_cfg(function*, bool)
/testing/gcc/gcc_src_master/gcc/tree-cfg.c:5578
0x110638f execute_function_todo
/testing/gcc/gcc_src_master/gcc/passes.c:2084
0x110693b execute_todo
/testing/gcc/gcc_src_master/gcc/passes.c:2138

gcc version 12.0.0 20211129 (ca5667e867252db3c8642ee90f55427149cd92b6) (GCC)

[Bug tree-optimization/103399] New: [12 Regression] Wrong code with -O2

2021-11-23 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103399

Bug ID: 103399
   Summary: [12 Regression] Wrong code with -O2
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Link to the Compiler Explorer: https://godbolt.org/z/3GE6fKvYr

Reproducer:

#include 
char a = 0;
long long b[8][10][18];
void e(int, long long[][10][18]) __attribute__((noipa));
void e(int f, long long g[][10][18]) {
  for (int d = 0; d < f; d += 3LL)
for (int c = 0; c < ((f ? g[5][0][0] : 0) ^ g[5][0][0]) + 1; c++)
  a = 42;
}
int main() {
  for (size_t i = 0; i < 8; ++i)
for (size_t k = 0; k < 10; ++k)
  for (size_t j = 0; j < 8; ++j)
b[i][k][j] = -1311387439415292401LL;
  e(8, b);
  printf("%u\n", a);
  if (a != 42)
__builtin_abort();
}

Error:
>$ g++ -O1 driver.cpp && ./a.out
42
>$ g++ -O2 driver.cpp && ./a.out
0

gcc version 12.0.0 20211123 (721d8b9e26bf8205c1f2125c2626919a408cdbe4) (GCC)

[Bug tree-optimization/103361] New: ICE in adjust_unroll_factor, at gimple-loop-jam.c:407

2021-11-22 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103361

Bug ID: 103361
   Summary: ICE in adjust_unroll_factor, at gimple-loop-jam.c:407
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Link to the Compiler Explorer: https://godbolt.org/z/jbKEn7Tdq

Reproducer:
char a, b;
extern unsigned short c[];
extern bool d[];
const unsigned short (const unsigned short , const unsigned short ) {
  if (g < f)
return g;
  return f;
}
void k() {
  for (int h = 0; b; h += 3)
for (unsigned long i = 0; i < 11104842004558084287ULL;
 i += -11104842004558084300ULL)
  for (bool j(e(6, e(6, c[h + i]))); j < (bool)a; j = 7)
d[7] = 0;
}

Error:
>$ g++ -O3 -c func.cpp
during GIMPLE pass: unrolljam
func.cpp: In function 'void k()':
func.cpp:9:6: internal compiler error: in adjust_unroll_factor, at
gimple-loop-jam.c:407
9 | void k() {
  |  ^
0x93ebce adjust_unroll_factor
/testing/gcc/gcc_src_master/gcc/gimple-loop-jam.c:407
0x93ebce tree_loop_unroll_and_jam
/testing/gcc/gcc_src_master/gcc/gimple-loop-jam.c:551
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

gcc version 12.0.0 20211121 (8fef6f720a5a0a056abfa986ba870bb406ab4716) (GCC)

[Bug tree-optimization/103321] [12 regression] ICE at tree-ssa.c:1211 after r12-5300

2021-11-18 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103321

Vsevolod Livinskiy  changed:

   What|Removed |Added

 CC||vsevolod.livinskij at frtk dot 
ru

--- Comment #4 from Vsevolod Livinskiy  ---
The same error can be triggered for X86.
Here is the link to the Compiler Explorer: https://godbolt.org/z/8zMhfhs5o

This reproducer was found with YARPGen.

Reproducer:
long a;
short b;
extern unsigned long d[];
const unsigned long long (const unsigned long long ,
const unsigned long long ) {
  if (f < g)
return g;
  return f;
}
const unsigned long long (const unsigned long long ,
const unsigned long long ) {
  return f < g ? f : g;
}
void j() {
  for (int i = 0;; i = 8)
d[i] = h(e(a, c[i] && b), 7);
}

Error:
>$ g++ -O2 -c func.cpp
func.cpp: In function 'void j()':
func.cpp:15:6: error: definition in block 5 does not dominate use in block 3
   15 | void j() {
  |  ^
for SSA_NAME: _23 in statement:
_6 = PHI <_4(5), _23(3), _23(4)>
PHI argument
_23
for PHI node
_6 = PHI <_4(5), _23(3), _23(4)>
during GIMPLE pass: phiopt
func.cpp:15:6: internal compiler error: verify_ssa failed
0x141284f verify_ssa(bool, bool)
/testing/gcc/gcc_src_master/gcc/tree-ssa.c:1211
0x10e86d5 execute_function_todo
/testing/gcc/gcc_src_master/gcc/passes.c:2049
0x10e901b execute_todo
/testing/gcc/gcc_src_master/gcc/passes.c:2096
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

gcc version 12.0.0 2028 (d6ec661e3931773e2f571ed4f6dd8b0402d8687d) (GCC)

[Bug tree-optimization/103122] New: [12 Regression] ICE in fill_block_cache, at gimple-range-cache.cc:1277 with -O2

2021-11-07 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103122

Bug ID: 103122
   Summary: [12 Regression] ICE in fill_block_cache, at
gimple-range-cache.cc:1277 with -O2
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Link to the Compiler Explorer: https://godbolt.org/z/GWbbq3sKK
Reproducer:
unsigned a;
int b;
short c;
void d(long) {
  for (bool e = (bool)c - 1; e < (bool)b - 1; e += 0)
;
  if (a) {
for (char f = 0; f < 7; f = 7)
  for (int g = 0; g < c; g += 10)
;
d(-!c);
  }
}

Error:
>$ g++ -O2 -c func.cpp
during GIMPLE pass: evrp
func.cpp: In function 'void d(long int)':
func.cpp:13:1: internal compiler error: in fill_block_cache, at
gimple-range-cache.cc:1277
   13 | }
  | ^
0x9e79d7 ranger_cache::fill_block_cache(tree_node*, basic_block_def*,
basic_block_def*)
/testing/gcc/gcc_src_master/gcc/gimple-range-cache.cc:1277
0x1ed1ecd ranger_cache::block_range(irange&, basic_block_def*, tree_node*,
bool)
/testing/gcc/gcc_src_master/gcc/gimple-range-cache.cc:1107
0x1ecc4f8 gimple_ranger::range_of_expr(irange&, tree_node*, gimple*)
/testing/gcc/gcc_src_master/gcc/gimple-range.cc:92
0xee7dff expr_not_equal_to(tree_node*, generic_wide_int
const&)
/testing/gcc/gcc_src_master/gcc/fold-const.c:10733
0xeec8e3 tree_single_nonzero_warnv_p(tree_node*, bool*)
/testing/gcc/gcc_src_master/gcc/fold-const.c:15244
0xeed076 tree_expr_nonzero_p(tree_node*)
/testing/gcc/gcc_src_master/gcc/fold-const.c:10706
0xefe7a8 fold_binary_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*)
/testing/gcc/gcc_src_master/gcc/fold-const.c:12284
0xf0254d fold_build2_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*)
/testing/gcc/gcc_src_master/gcc/fold-const.c:13774
0x13fe25c simplify_using_initial_conditions(loop*, tree_node*)
/testing/gcc/gcc_src_master/gcc/tree-ssa-loop-niter.c:2353
0x1404cd7 simplify_using_initial_conditions(loop*, tree_node*)
/testing/gcc/gcc_src_master/gcc/tree-ssa-loop-niter.c:2333
0x1404cd7 number_of_iterations_exit_assumptions(loop*, edge_def*,
tree_niter_desc*, gcond**, bool, basic_block_def**)
/testing/gcc/gcc_src_master/gcc/tree-ssa-loop-niter.c:2590
0x1405be2 number_of_iterations_exit_assumptions(loop*, edge_def*,
tree_niter_desc*, gcond**, bool, basic_block_def**)
/testing/gcc/gcc_src_master/gcc/tree-ssa-loop-niter.c:2825
0x1405be2 number_of_iterations_exit(loop*, edge_def*, tree_niter_desc*, bool,
bool, basic_block_def**)
/testing/gcc/gcc_src_master/gcc/tree-ssa-loop-niter.c:2812
0x135f6f0 number_of_latch_executions(loop*)
/testing/gcc/gcc_src_master/gcc/tree-scalar-evolution.c:2813
0x1405ef5 estimate_numbers_of_iterations(loop*)
/testing/gcc/gcc_src_master/gcc/tree-ssa-loop-niter.c:4356
0x1408c87 max_loop_iterations(loop*,
generic_wide_int >*)
/testing/gcc/gcc_src_master/gcc/tree-ssa-loop-niter.c:4462
0x15d2f6f bounds_of_var_in_loop(tree_node**, tree_node**, range_query*, loop*,
gimple*, tree_node*)
/testing/gcc/gcc_src_master/gcc/vr-values.c:1708
0x1ed6641 fold_using_range::range_of_ssa_name_with_loop_info(irange&,
tree_node*, loop*, gphi*, fur_source&)
/testing/gcc/gcc_src_master/gcc/gimple-range-fold.cc:1282
0x1ed6e1e fold_using_range::range_of_phi(irange&, gphi*, fur_source&)
/testing/gcc/gcc_src_master/gcc/gimple-range-fold.cc:837
0x1ed8e50 fold_using_range::fold_stmt(irange&, gimple*, fur_source&,
tree_node*)
/testing/gcc/gcc_src_master/gcc/gimple-range-fold.cc:554
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

GCC version:
gcc version 12.0.0 20211107 (9defce622893f87d954e0089e0ea79e1e388a480) (GCC)

[Bug tree-optimization/103119] New: ICE in get_imports, at gimple-range-gori.cc:230

2021-11-07 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103119

Bug ID: 103119
   Summary: ICE in get_imports, at gimple-range-gori.cc:230
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

The bug is not reproducible on the trunk anymore (the reduction process took
forever).
I don't know if it was fixed or became latent. Feel free to close it if it is
not relevant anymore.

Reproducer:
unsigned short a;
bool b;
int h, f;
extern bool d[][1];
char g;
void i() {
  for (short c = 0; c < 10; c += 3)
for (unsigned e = 0; e < a; e = (d[c][0] ? true : 5) * (6021496ULL * b) ?:
f)
  h = g;
}

Error:
>$ g++ -O2 -c func.cpp
during GIMPLE pass: vrp
func.cpp: In function 'void i()':
func.cpp:6:6: internal compiler error: in get_imports, at
gimple-range-gori.cc:230
6 | void i() {
  |  ^
0x9e98e5 range_def_chain::get_imports(tree_node*)
/testing/gcc/gcc_src_master/gcc/gimple-range-gori.cc:230
0x1edc480 range_def_chain::register_dependency(tree_node*, tree_node*,
basic_block_def*)
/testing/gcc/gcc_src_master/gcc/gimple-range-gori.cc:288
0x1edb976 range_def_chain::get_def_chain(tree_node*)
/testing/gcc/gcc_src_master/gcc/gimple-range-gori.cc:383
0x1edbf98 range_def_chain::in_chain_p(tree_node*, tree_node*)
/testing/gcc/gcc_src_master/gcc/gimple-range-gori.cc:198
0x1ede29b gori_compute::compute_operand_range(irange&, gimple*, irange const&,
tree_node*, fur_source&)
/testing/gcc/gcc_src_master/gcc/gimple-range-gori.cc:725
0x1edef21 gori_compute::compute_operand1_range(irange&, gimple*, irange const&,
tree_node*, fur_source&)
/testing/gcc/gcc_src_master/gcc/gimple-range-gori.cc:1078
0x1ede699 gori_compute::compute_operand_range(irange&, gimple*, irange const&,
tree_node*, fur_source&)
/testing/gcc/gcc_src_master/gcc/gimple-range-gori.cc:761
0x1edf989 gori_compute::outgoing_edge_range_p(irange&, edge_def*, tree_node*,
range_query&)
/testing/gcc/gcc_src_master/gcc/gimple-range-gori.cc:1259
0x1ed28c5 ranger_cache::range_on_edge(irange&, edge_def*, tree_node*)
/testing/gcc/gcc_src_master/gcc/gimple-range-cache.cc:983
0x1ed2b69 ranger_cache::propagate_cache(tree_node*)
/testing/gcc/gcc_src_master/gcc/gimple-range-cache.cc:1082
0x1ecdd9d gimple_ranger::range_of_stmt(irange&, gimple*, tree_node*)
/testing/gcc/gcc_src_master/gcc/gimple-range.cc:280
0x15d1934 simplify_using_ranges::fold_cond(gcond*)
/testing/gcc/gcc_src_master/gcc/vr-values.c:3492
0x15d1ea8 simplify_using_ranges::simplify_cond_using_ranges_1(gcond*)
/testing/gcc/gcc_src_master/gcc/vr-values.c:3568
0x15d6f87 simplify_using_ranges::simplify(gimple_stmt_iterator*)
/testing/gcc/gcc_src_master/gcc/vr-values.c:4386
0x154e3c8 rvrp_folder::fold_stmt(gimple_stmt_iterator*)
/testing/gcc/gcc_src_master/gcc/tree-vrp.c:4324
0x14434d6 substitute_and_fold_dom_walker::before_dom_children(basic_block_def*)
/testing/gcc/gcc_src_master/gcc/tree-ssa-propagate.c:870
0x1e9c847 dom_walker::walk(basic_block_def*)
/testing/gcc/gcc_src_master/gcc/domwalk.c:309
0x1442689 substitute_and_fold_engine::substitute_and_fold(basic_block_def*)
/testing/gcc/gcc_src_master/gcc/tree-ssa-propagate.c:987
0x15442c1 execute_ranger_vrp(function*, bool)
/testing/gcc/gcc_src_master/gcc/tree-vrp.c:4349
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

GCC version:
gcc version 12.0.0 20211105 (614b39757b8b61f70ac1c666edb7a01a5fc19cd4) (GCC)

[Bug ipa/103073] [12 Regression] ICE in insert_access, at ipa-modref-tree.h:578 since r12-4401-gfecd145359fc981b

2021-11-04 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103073

--- Comment #4 from Vsevolod Livinskiy  ---
(In reply to Martin Liška from comment #2)
> Started with r12-4401-gfecd145359fc981b.
> 
> @Vsevolod: Is it a yarpgen test-case?

Yes. I've added stencil support recently, but it was a surprise to trigger a
bug in IPA.

BTW, should I add new bugs to the meta-bug before or after they were confirmed?

[Bug ipa/103073] New: [12 Regression] ICE in insert_access, at ipa-modref-tree.h:578

2021-11-03 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103073

Bug ID: 103073
   Summary: [12 Regression] ICE in insert_access, at
ipa-modref-tree.h:578
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ipa
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

I'm not sure about the component. Would you mind checking and fixing it in case
it is wrong?

Link to the Compiler Explorer: https://godbolt.org/z/K17Grnez9

Reproducer:
int a;
void b(bool c[], char d[], bool g[][55][21]) {
  for (signed e = 0; e < 11; e += 3)
for (unsigned f = c[0] + 1; f < d[0]; f += 3)
  a = g[0][e][f + 2];
}

Error:
>$ g++ -c func.cpp -O3
during GIMPLE pass: modref
func.cpp: In function 'void b(bool*, char*, bool (*)[55][21])':
func.cpp:2:6: internal compiler error: in insert_access, at
ipa-modref-tree.h:578
2 | void b(bool c[], char d[], bool g[][55][21]) {
  |  ^
0x103ae7a modref_ref_node::insert_access(modref_access_node, unsigned
long, bool)
/testing/gcc/gcc_src_master/gcc/ipa-modref-tree.h:578
0x103b16d modref_tree::insert(int, int, modref_access_node, bool)
/testing/gcc/gcc_src_master/gcc/ipa-modref-tree.h:848
0x102cafe record_access
/testing/gcc/gcc_src_master/gcc/ipa-modref.c:758
0x102d7ff analyze_load
/testing/gcc/gcc_src_master/gcc/ipa-modref.c:1262
0xf84246 walk_stmt_load_store_addr_ops(gimple*, void*, bool (*)(gimple*,
tree_node*, tree_node*, void*), bool (*)(gimple*, tree_node*, tree_node*,
void*), bool (*)(gimple*, tree_node*, tree_node*, void*))
/testing/gcc/gcc_src_master/gcc/gimple-walk.c:800
0x1034872 analyze_stmt
/testing/gcc/gcc_src_master/gcc/ipa-modref.c:1313
0x1034872 analyze_function
/testing/gcc/gcc_src_master/gcc/ipa-modref.c:2366
0x1035e21 execute
/testing/gcc/gcc_src_master/gcc/ipa-modref.c:3213
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

GCC version:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/testing/gcc/bin_master/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /testing/gcc/gcc_src_master/configure --enable-multilib
--prefix=/testing/gcc/bin_master --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20211103 (62af7d9402f551fa708125fafed2950d8912b25e) (GCC)

[Bug tree-optimization/103037] New: [11/12 Regression] Wrong code with -O2

2021-11-02 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103037

Bug ID: 103037
   Summary: [11/12 Regression] Wrong code with -O2
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Link to the Compiler Explorer: https://godbolt.org/z/eaGzsPnax

Reproducer:
#include 

short var_3 = 2;
unsigned char var_9 = 23;
unsigned short var_11;
unsigned short arr_4 [23];

void test() __attribute__((noipa));

const unsigned short (unsigned short , const unsigned short ) {
  return e < d ? e : d;
}

void test() {
  for (int a = 0; a < var_9; a += 3)
  var_11 = min(arr_4[a], 1) / (arr_4[a] ? arr_4[a] : var_3);
}


int main() {
for (size_t i_0 = 0; i_0 < 23; ++i_0)
arr_4 [i_0] = 2;
test();
printf("%hu\n", var_11);
if (var_11 != 0)
__builtin_abort();

}

Error:
>$ g++ driver.cpp -O0 && ./a.out
0
>$ g++ driver.cpp -O2 && ./a.out
1

GCC version:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/testing/gcc/bin_master/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /testing/gcc/gcc_src_master/configure --enable-multilib
--prefix=/testing/gcc/bin_master --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20211101 (679652a77da60078392a834ed4b6b910127dbf24) (GCC)

[Bug tree-optimization/95916] [11 Regression] ICE during GIMPLE pass: slp : verify_ssa failed

2021-11-01 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95916

Richard Biener  changed:

   What|Removed |Added

 CC||dcb314 at hotmail dot com

Vsevolod Livinskiy  changed:

   What|Removed |Added

 Blocks||103035

--- Comment #6 from Richard Biener  ---
*** Bug 95987 has been marked as a duplicate of this bug. ***


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103035
[Bug 103035] [meta-bug] YARPGen bugs

[Bug tree-optimization/103035] New: [meta-bug] YARPGen bugs

2021-11-01 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103035

Bug ID: 103035
   Summary: [meta-bug] YARPGen bugs
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

This is a meta-bug that is supposed to keep track of bugs that were found with
YARPGen (https://github.com/intel/yarpgen).

YARPGen is a random program generator, which produces correct runnable C/C++.
We use it to fuzz GCC and other compilers.

Special thanks to Martin Liška for submitting some of them.

If you use YARPGen to report a bug, please add it to this meta-bug.

[Bug tree-optimization/102920] New: [12 Regression] Wrong code with -O3

2021-10-24 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102920

Bug ID: 102920
   Summary: [12 Regression] Wrong code with -O3
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

https://godbolt.org/z/qn3dsxsW8

Reproducer:
#include 

unsigned short a = 42;
unsigned short b = 1;
long long int c = 1;
unsigned char var_120;
unsigned char var_123;

void test(unsigned short a, unsigned short b, long long int c)
__attribute__((noipa));

void test(unsigned short a, unsigned short b, long long c) {
for (char i = 0; i < (char)c; i += 5)
if (!b)
var_120 = a;
else
var_123 = a;
}

int main() {
test(a, b, c);
printf("%hhu\n", var_123);
//if (var_123 != 42)
//__builtin_abort();
}

Error:
>$ g++ -O3 small.cpp && ./a.out
0
>$ g++ -O2 small.cpp && ./a.out
42

GCC version:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/testing/gcc/bin_master/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /testing/gcc/gcc_src_master/configure --enable-multilib
--prefix=/testing/gcc/bin_master --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20211023 (experimental) (GCC) 
root@abe71269b867:/testing/result/S_1635079215/reduce# cat
/testing/gcc/gcc_rev.txt 
git://gcc.gnu.org/git/gcc.git:master
e3725624ec0735996a18e1a90317e230bef899ac

[Bug tree-optimization/102788] New: Wrong code with -O3

2021-10-15 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102788

Bug ID: 102788
   Summary: Wrong code with -O3
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Link to the Compiler Explorer: https://godbolt.org/z/78ab77Env

Reproducer:
#include 

unsigned long long int var_4 = 235;
unsigned long long int var_5 = 74;
signed char var_12 = -99;
unsigned long long int var_349;
unsigned char var_645;
void test();

const unsigned long long (const unsigned long long , const unsigned long
long ) {
  return b < a ? b : a;
}

void test() __attribute__((noipa));
void test() {
for (short c = var_12; c; c += 5)
  ; 
for (int e = 0; e < 12; e += 1) {
  var_349 = var_4 ? 235 : 74;
  var_645 = min((unsigned long long)true, var_5 ? var_12 : var_4);
}
}

int main() {
test();
printf("%d\n", (int)var_645);
//if (var_645 != 1)
//  __builtin_abort();
}

Error:
>$g++ -O2 small.cpp && ./a.out 
1
>$g++ -O3 small.cpp && ./a.out 
255

GCC version:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/testing/gcc/bin_master/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /testing/gcc/gcc_src_master/configure --enable-multilib
--prefix=/testing/gcc/bin_master --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20211011 (30cce6f65a77b8eaa22f3efff7f1ba54858106f9) (GCC)

[Bug tree-optimization/102696] New: ICE in vect_build_slp_tree, at tree-vect-slp.c:1551 for skylake-avx512 and icelake-server

2021-10-11 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102696

Bug ID: 102696
   Summary: ICE in vect_build_slp_tree, at tree-vect-slp.c:1551
for skylake-avx512 and icelake-server
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Link to the Compiler Explorer:
https://godbolt.org/z/WhYP35KKT

Reproducer:

int a;
extern bool b[][14];
char h;
void f(short g[][14]) {
for (short d = h; d < 21; d += 1)
  for (unsigned char e = 0; e < 14; e += 1) {
a = 0;
b[d][e] = g[d][e];
  }
}

Error:
>$ g++ -c -O3 -march=skylake-avx512 func.cpp
during GIMPLE pass: slp
func.cpp: In function 'void f(short int (*)[14])':
func.cpp:4:6: internal compiler error: in vect_build_slp_tree, at
tree-vect-slp.c:1551
4 | void f(short g[][14]) {
  |  ^
0x153e92a vect_build_slp_tree
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1551
0x153ee59 vect_build_slp_tree_2
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:2199
0x153e41c vect_build_slp_tree
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1532
0x153ee59 vect_build_slp_tree_2
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:2199
0x153e41c vect_build_slp_tree
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1532
0x153ee59 vect_build_slp_tree_2
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:2199
0x153e41c vect_build_slp_tree
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1532
0x153ee59 vect_build_slp_tree_2
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:2199
0x153e41c vect_build_slp_tree
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:1532
0x1543ac2 vect_build_slp_instance
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3012
0x1544d35 vect_analyze_slp_instance
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3332
0x1543d96 vect_build_slp_instance
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3230
0x1544d35 vect_analyze_slp_instance
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3332
0x1543d96 vect_build_slp_instance
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3230
0x1544d35 vect_analyze_slp_instance
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3332
0x154979a vect_analyze_slp(vec_info*, unsigned int)
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:3365
0x154d316 vect_slp_analyze_bb_1
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:5746
0x154d316 vect_slp_region
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:5848
0x154f495 vect_slp_bbs
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:6040
0x154f799 vect_slp_function(function*)
/testing/gcc/gcc_src_master/gcc/tree-vect-slp.c:6128
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
root@86380205c3f4:/testing/result/S_3142105512/reduce# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/testing/gcc/bin_master/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /testing/gcc/gcc_src_master/configure --enable-multilib
--prefix=/testing/gcc/bin_master --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib

gcc version 12.0.0 20211011 (30cce6f65a77b8eaa22f3efff7f1ba54858106f9) (GCC)

[Bug tree-optimization/102622] New: Wrong code with -O3 for skylake-avx512 and icelake-server

2021-10-05 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102622

Bug ID: 102622
   Summary: Wrong code with -O3 for skylake-avx512 and
icelake-server
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Reproducer:
// func.cpp
#include 

extern int var_20, var_22;
extern short arr_32[];
extern char arr_45[];

void test(int a, unsigned b, long long *c) {
  for (short d = 0; d < 13; d++) {
for (int e = 0; e < a; e += 3)
  var_20 = 0;
if (std::max(b, unsigned((short)b))) {
  arr_32[d] = 0;
  var_22 = *c;
}
for (unsigned f = 0; f < 69; f += 4)
  arr_45[f] = 0;
  }
}

driver.cpp
#include 

unsigned long long int a = 10693271954245845448ULL;
unsigned int b = 1144022456U;
long long int c = 42;
int var_20 = 0;
long long int var_22 = 0;
unsigned short arr_32 [13];
unsigned char arr_45 [69];

void test(int a, unsigned int b, long long int* c);

int main() {
test(a, b, );
printf("%llu\n", var_22);
}

Error:
>$ g++ -O3 -march=skylake-avx512 func.cpp driver.cpp && sde -skx -- ./a.out 
0
>$ g++ -O2 -march=skylake-avx512 func.cpp driver.cpp && sde -skx -- ./a.out 
42

GCC version:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/testing/gcc/bin/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /testing/gcc/gcc_src/configure --enable-multilib
--prefix=/testing/gcc/bin --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20211004 (154fd0896ef22fcf5235e35e2b7953947a33) (GCC)

[Bug tree-optimization/102572] New: ICE for skx in vect_build_gather_load_calls, at tree-vect-stmts.c:2835

2021-10-02 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102572

Bug ID: 102572
   Summary: ICE for skx in vect_build_gather_load_calls, at
tree-vect-stmts.c:2835
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Reproducer:
int a, b, c, f;
void g(bool h, int d[][5]) {
  for (short i = f; i; i += 1) {
a = h && d[0][i];
for (int j = 0; j < 4; j += c)
  b = 0;
  }
}

Error:

>$ g++ -O3 -march=skylake-avx512 -c func.cpp
during GIMPLE pass: vect
func.cpp: In function 'void g(bool, int (*)[5])':
func.cpp:2:6: internal compiler error: in vect_build_gather_load_calls, at
tree-vect-stmts.c:2835
2 | void g(bool h, int d[][5]) {
  |  ^
0x906a36 vect_build_gather_load_calls
/testing/gcc/gcc_src/gcc/tree-vect-stmts.c:2835
0x906a36 vectorizable_load
/testing/gcc/gcc_src/gcc/tree-vect-stmts.c:8785
0x1500240 vect_transform_stmt(vec_info*, _stmt_vec_info*,
gimple_stmt_iterator*, _slp_tree*, _slp_instance*)
/testing/gcc/gcc_src/gcc/tree-vect-stmts.c:11060
0x1503e6a vect_transform_loop_stmt
/testing/gcc/gcc_src/gcc/tree-vect-loop.c:9362
0x151fd67 vect_transform_loop(_loop_vec_info*, gimple*)
/testing/gcc/gcc_src/gcc/tree-vect-loop.c:9798
0x1553a8f try_vectorize_loop_1
/testing/gcc/gcc_src/gcc/tree-vectorizer.c:1109
0x1554591 vectorize_loops()
/testing/gcc/gcc_src/gcc/tree-vectorizer.c:1248

GCC version:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/testing/gcc/bin/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /testing/gcc/gcc_src/configure --enable-multilib
--prefix=/testing/gcc/bin --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20211002 (d7705b0ada9e9852b580ca25a45570c82152f287) (GCC)

[Bug tree-optimization/102511] New: GCC produces incorrect code for -O3: first element of the array is skipped

2021-09-27 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102511

Bug ID: 102511
   Summary: GCC produces incorrect code for -O3: first element of
the array is skipped
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Reproducer:
//func.cpp
extern char arr_15[];
void test(signed char a, unsigned short b, unsigned long long c,
  unsigned short f) {
  for (int d = b - 8; d < b; d += 2)
for (short e = 0; e < (unsigned short)((f ? 122 : 0) ^ (a ? c : 0)) -
64055;
 e += 3)
  arr_15[d] = 42;
}

//driver.cpp 
#include 

unsigned char arr_15 [8];

void test(signed char a, unsigned short b, unsigned long long int c, unsigned
short f);

int main() {
test(37, 8, 12325048486467861044ULL, 45936);
for (size_t i_0 = 0; i_0 < 8; ++i_0)
printf("%d ", arr_15 [i_0]);
printf("\n");
}

Error:
>$ g++ -O3 driver.cpp func.cpp && ./a.out 
0 0 42 0 42 0 42 0 
>$ g++ -O2 driver.cpp func.cpp && ./a.out 
42 0 42 0 42 0 42 0 

GCC version:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/testing/gcc/bin/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /testing/gcc/gcc_src/configure --enable-multilib
--prefix=/testing/gcc/bin --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210927 (51018dd1395c72b3681ae5f84eceb94320472922) (GCC)

[Bug tree-optimization/99777] New: ICE in build2, at tree.c:4869 with -O3

2021-03-25 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99777

Bug ID: 99777
   Summary: ICE in build2, at tree.c:4869 with -O3
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

The error is not specific to skylake-avx512, I have a reproducer that shows it.

Reproducer:
#include 

extern int var_142;
extern int a, c;
long h;
unsigned long long e;
signed char d;
extern short arr_323[][7][5][30];

void test(long long b,
  short f[][17][25][22][20]) {
  for (char i = 0; i < 7; i += 3)
for (unsigned char l = e; l < 5; l += 2) {
  if (std::max((long long)0, std::min((long long)7, b)))
for (bool j = 0; j < 1; j = b) {
  for (unsigned k = d; k < 20; k++)
h = f[0][i][l][b][k];
  for (int m = 0; m < 5; m++)
arr_323[c][i][l][m] = 0;
}
  for (int n = 0; n < 4; n += a)
var_142 = n;
}
}

Error:
>$ g++ -O3 -march=skylake-avx512 func.cpp -c
during GIMPLE pass: lim
func.cpp: In function ‘void test(long long int, short int
(*)[17][25][22][20])’:
func.cpp:10:6: internal compiler error: in build2, at tree.c:4869
   10 | void test(long long b,
  |  ^~~~
0x85386f build2(tree_code, tree_node*, tree_node*, tree_node*)
gcc/gcc_src/gcc/tree.c:4869
0xddb96f build2_loc
gcc/gcc_src/gcc/tree.h:4407
0xddb96f fold_build2_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*)
gcc/gcc_src/gcc/fold-const.c:13736
0xde8de3 extract_muldiv_1
gcc/gcc_src/gcc/fold-const.c:6976
0xdea422 extract_muldiv
gcc/gcc_src/gcc/fold-const.c:6662
0xdea422 extract_muldiv
gcc/gcc_src/gcc/fold-const.c:6662
0xdea422 extract_muldiv
gcc/gcc_src/gcc/fold-const.c:6662
0xdd6bb1 fold_binary_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*)
gcc/gcc_src/gcc/fold-const.c:11486
0xddb94d fold_build2_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*)
gcc/gcc_src/gcc/fold-const.c:13734
0x1c3b096 aff_combination_add_elt(aff_tree*, tree_node*,
generic_wide_int > const&)
gcc/gcc_src/gcc/tree-affine.c:187
0x1c3b3d5 aff_combination_add(aff_tree*, aff_tree*)
gcc/gcc_src/gcc/tree-affine.c:215
0x124fc0f mem_refs_may_alias_p
gcc/gcc_src/gcc/tree-ssa-loop-im.c:1718
0x124fc83 refs_independent_p
gcc/gcc_src/gcc/tree-ssa-loop-im.c:2703
0x12502b4 ref_indep_loop_p
gcc/gcc_src/gcc/tree-ssa-loop-im.c:2764
0x1255ff4 can_sm_ref_p
gcc/gcc_src/gcc/tree-ssa-loop-im.c:2832
0x1255ff4 find_refs_for_sm
gcc/gcc_src/gcc/tree-ssa-loop-im.c:2853
0x1255ff4 store_motion_loop
gcc/gcc_src/gcc/tree-ssa-loop-im.c:2889
0x1255ddc store_motion_loop
gcc/gcc_src/gcc/tree-ssa-loop-im.c:2896
0x1255ddc store_motion_loop
gcc/gcc_src/gcc/tree-ssa-loop-im.c:2896
0x1258262 do_store_motion
gcc/gcc_src/gcc/tree-ssa-loop-im.c:2911

gcc version 11.0.1 20210323 (6b1f841ce0ccf30eda7896ba5ab0aa94c72307b2) (GCC)

[Bug tree-optimization/98694] New: GCC produces incorrect code for loops with -O3 for skylake-avx512 and icelake-server

2021-01-14 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98694

Bug ID: 98694
   Summary: GCC produces incorrect code for loops with -O3 for
skylake-avx512 and icelake-server
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

The reproducer is a bit big, but I was not able to reduce it further.
Reproducer:

// func.cpp
#include 

extern short var_1, var_29, var_89;
extern unsigned var_2, var_11;
extern bool var_4;
extern long var_6;
extern char var_7;
extern int var_8, var_10;
extern short arr_206[10][14][13][21][14] __attribute__((aligned));
extern int arr_257[];

long f(long l) { return 0 > l ? 0 : l; }

void test() {
  var_11 = var_6;
  for (char a = 0; a < (char)var_2; a = 6)
for (int b = 0; b < var_2; b = ~0)
  for (int c = 0; c < 2; c = var_1)
for (bool d = 0; d < var_4; d = 1)
  var_29 = f(~var_6);
  for (short e = 0; e < short(var_6); e = var_6) {
for (; 0 < (int)var_6;)
  ;
for (char g = 0; g < 4; g++)
  for (; std::min(var_7 / 405077347810ULL, (unsigned long long)9);
   var_7 += 2)
for (char h = 0; h < (char)var_8; h += 4)
  for (short i = 0; i < (var_4 && var_6) + 13; i++) {
arr_206[0][g][0][h][i] = var_6;
var_89 = std::min(var_4 ?: 709U, (unsigned)var_4);
  }
for (short j = 0; j < var_2; j += 4)
  for (int k = 0; k < 5U; k = var_10)
arr_257[k] = var_6;
  }
}

// driver.cpp
#include 

short var_1 = (short)7531;
unsigned int var_2 = 187158918U;
bool var_4 = (bool)1;
unsigned long long int var_6 = 10263287916162477044ULL;
signed char var_7 = 0;
long long int var_8 = 21;
unsigned int var_10 = 3309705747U;
unsigned int var_11 = 222967114U;
short var_29 = (short)-22723;
short var_89 = (short)-19017;
short arr_206 [10] [14] [13] [21] [14] __attribute__((aligned));
int arr_257 [5];

void test();

int main() {
test();
for (size_t i_0 = 0; i_0 < 5; ++i_0)
printf("%d ", arr_257 [i_0]);
printf("\n");
}

Error:

>$ g++ -march=skylake-avx512 func.cpp driver.cpp -O2 && sde -skx -- ./a.out 
-2039714828 0 0 0 0 
>$ g++ -march=skylake-avx512 func.cpp driver.cpp -O3 && sde -skx -- ./a.out 
27636 0 0 0 0

gcc version 11.0.0 20210113 (8fc183ccd0628465205b8a88c29ab69bfe74a08a)

[Bug tree-optimization/98640] New: GCC produces incorrect code with -O1 and higher

2021-01-12 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98640

Bug ID: 98640
   Summary: GCC produces incorrect code with -O1 and higher
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Reproducer:
#include 

unsigned long long int var_0 = 18128133247277979402ULL;
long long int var_14 = 6557021550272328915LL;
unsigned long long int var_83 = 10966786425750692026ULL;

void test() {
  var_14 = var_0 + (bool)7;
  var_83 = 1 + (int)var_0; // 1 + 888395530
}

int main() {
test();
printf("%llu\n", var_83);
}

https://godbolt.org/z/axYx1f

>$ g++ -O0 driver.cpp && ./a.out 
888395531
>$ g++ -O1 driver.cpp && ./a.out 
18128133247277979403

gcc version 11.0.0 20210112 (cf2ac1c30af0fa783c8d72e527904dda5d8cc330)

[Bug tree-optimization/98381] New: Wrong code with -O3 -march=skylake-avx512

2020-12-18 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98381

Bug ID: 98381
   Summary: Wrong code with -O3 -march=skylake-avx512
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Reproducer:
//func.cpp
extern bool var_22;
void test(long long a, unsigned b, unsigned long long c) {
  for (long i = 0; i < 16; i += 1ULL)
if (a)
  var_22 = 5023804122334ULL >= (char)c;
}

//driver.cpp 
#include 
long long int a = -2161098602020439353LL;
unsigned int b = 1621447385U;
unsigned long long int c = 16505450185101189749ULL;
bool var_22 = (bool)0;

void test(long long int a, unsigned int b, unsigned long long int c);

int main() {
test(a, b, c);
printf("%d\n", (int)var_22);
}

Error:
>$ g++ -O3 -march=skylake-avx512 func.cpp driver.cpp && sde -skx -- ./a.out
0
>$ g++ -O0 func.cpp driver.cpp && sde -skx -- ./a.out
1

gcc version 11.0.0 20201217 (6f8486523f61bf0aa476dfa4197d1e3b71a0a8f3) (GCC)

[Bug tree-optimization/98308] New: ICe in in vect_slp_analyze_node_operations, at tree-vect-slp.c:3764 with -O3 -march=skylake-avx512

2020-12-15 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98308

Bug ID: 98308
   Summary: ICe in in vect_slp_analyze_node_operations, at
tree-vect-slp.c:3764 with -O3 -march=skylake-avx512
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Reproducer:
extern unsigned long long int arr_86[];
extern unsigned long long int arr_87[][15];

void test(bool a, unsigned short c[][15], unsigned char d[]) {
for (short h = 0; h < 10; h++)
for (char i = 0; i < 15; i += 2) {
arr_86[0] = d[0];
arr_87[h][0] = a ? c[h][i] : 0;
}
}

Error:
>$ g++ -c -O3 -march=skylake-avx512 func.cpp
during GIMPLE pass: vect
func.cpp: In function ‘void test(bool, short unsigned int (*)[15], unsigned
char*)’:
func.cpp:4:6: internal compiler error: in vect_slp_analyze_node_operations, at
tree-vect-slp.c:3764
4 | void test(bool a, unsigned short c[][15], unsigned char d[]) {
  |  ^~~~
0x886a4d vect_slp_analyze_node_operations
gcc_src/gcc/tree-vect-slp.c:3764
0x1425a73 vect_slp_analyze_node_operations
gcc_src/gcc/tree-vect-slp.c:3719
0x1425a73 vect_slp_analyze_node_operations
gcc_src/gcc/tree-vect-slp.c:3719
0x1425a73 vect_slp_analyze_node_operations
gcc_src/gcc/tree-vect-slp.c:3719
0x1427101 vect_slp_analyze_operations(vec_info*)
gcc_src/gcc/tree-vect-slp.c:3914
0x1404939 vect_analyze_loop_2
gcc_src/gcc/tree-vect-loop.c:2391
0x1404939 vect_analyze_loop(loop*, vec_info_shared*)
gcc_src/gcc/tree-vect-loop.c:2929
0x14311f4 try_vectorize_loop_1
gcc_src/gcc/tree-vectorizer.c:1008
0x1431c59 vectorize_loops()
gcc_src/gcc/tree-vectorizer.c:1242
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

gcc version 11.0.0 20201214 (22a90217305ee8c116bbc12c8d07abe7ca0ff61d)

[Bug tree-optimization/98069] New: Miscompilation with -O3

2020-11-30 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98069

Bug ID: 98069
   Summary: Miscompilation with -O3
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Reproducer:
//func.cpp
extern long long var_3;
extern short var_8;
extern int var_17;
extern short arr_165[];
long c(long e, long f) { return f ? e : f; }
void test() {
for (int b = 0; b < 19; b = var_17)
for (int d = int(~c(-2147483647 - 1, var_3)) - 2147483647; d < 22; d++)
arr_165[d] = var_8;
}

//driver.cpp 
#include 

long long int var_3 = -166416893043554447LL;
short var_8 = (short)27092;
unsigned int var_17 = 75036300U;
short arr_165[23];

void test();

int main() {
for (size_t i_3 = 0; i_3 < 23; ++i_3)
arr_165[i_3] = (short)-8885;
test();
printf("%d\n", arr_165[0]);
}

>$ g++ -O3 func.cpp driver.cpp && ./a.out
Segmentation fault (core dumped)
>$ g++ -O2 func.cpp driver.cpp && ./a.out
27092

gcc version 11.0.0 20201126 (beb9afcaf1466996a301c778596c5df209e7913c)

[Bug tree-optimization/98064] New: ICE in check_loop_closed_ssa_def, at tree-ssa-loop-manip.c:726 with -O3

2020-11-29 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98064

Bug ID: 98064
   Summary: ICE in check_loop_closed_ssa_def, at
tree-ssa-loop-manip.c:726 with -O3
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Error:
>$ g++ -c -O3 func.cpp
during GIMPLE pass: slp
func.cpp: In function ‘void test()’:
func.cpp:8:6: internal compiler error: in check_loop_closed_ssa_def, at
tree-ssa-loop-manip.c:726
8 | void test() {
  |  ^~~~
0x84b706 check_loop_closed_ssa_def
/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-ssa-loop-manip.c:726
0x12ae78d check_loop_closed_ssa_bb
/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-ssa-loop-manip.c:752
0x12b05d6 verify_loop_closed_ssa(bool, loop*)
/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-ssa-loop-manip.c:777
0x12b05d6 verify_loop_closed_ssa(bool, loop*)
/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-ssa-loop-manip.c:761
0x1062c24 execute_function_todo
/home/vlivinsk/workspace/gcc/gcc_src/gcc/passes.c:2057
0x10638ae execute_todo
/home/vlivinsk/workspace/gcc/gcc_src/gcc/passes.c:2093
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

Reproducer:
#include 
extern long var_2;
extern int var_3, var_8;
extern long long var_5;
extern unsigned short arr_353[];
extern short arr_362[];
extern int arr_518[];
void test() {
for (char d = 0; d < 013; d += 4) {
for (char e = 0; e < 11; e++)
arr_353[e] = var_2 | std::min((long long)7, var_5);
for (int f = var_5; f; f += 4)
for (short g = var_8; g; g++)
arr_362[g] = 0;
}
for (short h = 5; (short)var_2; h += 5)
arr_518[h] = 0;
}


gcc version 11.0.0 20201126 (beb9afcaf1466996a301c778596c5df209e7913c)

[Bug tree-optimization/98048] New: ICE in build_vector_from_val, at tree.c:1985

2020-11-28 Thread vsevolod.livinskij at frtk dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98048

Bug ID: 98048
   Summary: ICE in build_vector_from_val, at tree.c:1985
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Reproducer:
extern short var_0;
extern int var_3;
extern int arr_277[];
int a(int b, int c) { return b < c ? b : c; }
int e;
void test() {
  e = var_0;
  for (int d = 0; d < 9; d++)
if (var_3)
  arr_277[d] = a(var_0, -var_0);
}

Error:
>$ g++ -c -O3 func.cpp
during GIMPLE pass: veclower2
func.cpp: In function ‘void test()’:
func.cpp:6:6: internal compiler error: in build_vector_from_val, at tree.c:1985
6 | void test() {
  |  ^~~~
0x88bffd build_vector_from_val(tree_node*, tree_node*)
/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree.c:1985
0x13a22cd expand_vector_operations_1
/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-vect-generic.c:2095
0x13a22cd expand_vector_operations
/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-vect-generic.c:2291
0x13a22cd execute
/home/vlivinsk/workspace/gcc/gcc_src/gcc/tree-vect-generic.c:2337
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

gcc version 11.0.0 20201126 (beb9afcaf1466996a301c778596c5df209e7913c)