[Bug tree-optimization/107937] [13 Regression] ICE in find_var_cmp_const, at gimple-predicate-analysis.cc:257 since r13-4408-gb628cad9e093f7a3

2022-12-01 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107937

Richard Biener  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #10 from Richard Biener  ---
So we have

((getk_intersect_line_with_ycylinder_r.0_19 < 0.0) AND
(getk_intersect_line_with_ycylinder_r.0_19 u>= 0.0) AND (NOT (_180 != 0)))

from

 [local count: 711980952]:
# k2_184 = PHI 
# prephitmp_96 = PHI <_182(74), getk_intersect_line_with_ycylinder_i.4_30(81)>
getk_intersect_line_with_ycylinder_r.0_19 =
getk_intersect_line_with_ycylinder_r;
if (getk_intersect_line_with_ycylinder_r.0_19 < 0.0)
  goto ; [14.99%]
else
  goto ; [85.01%]

 [local count: 106727384]:
if (getk_intersect_line_with_ycylinder_r.0_19 u>= 0.0)
  goto ; [99.95%]
else
  goto ; [0.05%]

and we simplify that to true which is bogus.  It's correct to remove
this false sub-predicate from the (a || b || c ...) chain but when
it's the last the result is false, not true.

Fixed.

[Bug tree-optimization/107937] [13 Regression] ICE in find_var_cmp_const, at gimple-predicate-analysis.cc:257 since r13-4408-gb628cad9e093f7a3

2022-12-01 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107937

--- Comment #9 from CVS Commits  ---
The master branch has been updated by Richard Biener :

https://gcc.gnu.org/g:abf05583dbc86a6667b63f5bda6ba57fe55a1b25

commit r13-4437-gabf05583dbc86a6667b63f5bda6ba57fe55a1b25
Author: Richard Biener 
Date:   Thu Dec 1 10:12:28 2022 +0100

tree-optimization/107937 - uninit predicate simplification fixup

The following changes the predicate representation to record the
value of a predicate with an empty set of AND predicates.  That's
necessary to properly represent the conservative fallback for the
def vs use predicates.  Since simplification now can result in
such an empty set this distinction becomes important and we need
to check for this as we otherwise ICE.

PR tree-optimization/107937
* gimple-predicate-analysis.h (predicate::is_true): New.
(predicate::is_false): Likewise.
(predicate::empty_val): Likewise.
(uninit_analysis::uninit_analysis): Properly initialize
def_preds.
* gimple-predicate-analysis.cc (simplify_1b): Indicate
whether the chain became empty.
(predicate::simplify): Release emptied chain before removing it.
(predicate::normalize): Replace temporary object with assertion.
(uninit_analysis::is_use_guarded): Deal with predicates
that simplify to true/false.

* gcc.dg/pr107937.c: New testcase.

[Bug tree-optimization/107937] [13 Regression] ICE in find_var_cmp_const, at gimple-predicate-analysis.cc:257 since r13-4408-gb628cad9e093f7a3

2022-12-01 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107937

Zhendong Su  changed:

   What|Removed |Added

 CC||zhendong.su at inf dot ethz.ch

--- Comment #8 from Zhendong Su  ---
Another test:

[546] % gcctk -O3 -Wall -w small.c
during GIMPLE pass: uninit
small.c: In function ‘main’:
small.c:3:5: internal compiler error: in find_var_cmp_const, at
gimple-predicate-analysis.cc:257
3 | int main() {
  | ^~~~
0x818725 find_var_cmp_const
../../gcc-trunk/gcc/gimple-predicate-analysis.cc:257
0x1c9bfbf uninit_analysis::overlap(gphi*, unsigned int, hash_set >*, predicate const&)
../../gcc-trunk/gcc/gimple-predicate-analysis.cc:648
0x1c9bafa uninit_analysis::is_use_guarded(gimple*, basic_block_def*, gphi*,
unsigned int, hash_set >*)
../../gcc-trunk/gcc/gimple-predicate-analysis.cc:2215
0x1c9c0ec uninit_analysis::is_use_guarded(gimple*, basic_block_def*, gphi*,
unsigned int)
../../gcc-trunk/gcc/gimple-predicate-analysis.cc:2249
0x110d500 find_uninit_use
../../gcc-trunk/gcc/tree-ssa-uninit.cc:1234
0x110de96 warn_uninitialized_phi
../../gcc-trunk/gcc/tree-ssa-uninit.cc:1304
0x110de96 execute_late_warn_uninitialized
../../gcc-trunk/gcc/tree-ssa-uninit.cc:1425
0x110de96 execute
../../gcc-trunk/gcc/tree-ssa-uninit.cc:1442
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
[547] % cat small.c
int printf(const char *, ...);
int a, b;
int main() {
  int c, d;
  while (b) {
if (a) {
  
  c = ~c;
}
printf("0");
while (b && d && c)
  ;
  }
  return 0;
}

[Bug tree-optimization/107937] [13 Regression] ICE in find_var_cmp_const, at gimple-predicate-analysis.cc:257 since r13-4408-gb628cad9e093f7a3

2022-11-30 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107937

Richard Biener  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org

--- Comment #7 from Richard Biener  ---
Mine.

[Bug tree-optimization/107937] [13 Regression] ICE in find_var_cmp_const, at gimple-predicate-analysis.cc:257 since r13-4408-gb628cad9e093f7a3

2022-11-30 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107937

--- Comment #6 from Martin Liška  ---
Another test-case:

$ cat warn.i
int regs, vm_debug_engine_vp_0, vm_debug_engine_vp_2;

void
vm_dispatch_hook();


void
vm_debug_engine() {
  int fp;
  void *jump_table = &_nop;
l_nop:
  if (__builtin_expect(vm_debug_engine_vp_2, 0))
vm_dispatch_hook();
  if (_setjmp(regs)) {
fp = fp;
vm_dispatch_hook();
goto *jump_table;
  }
  vm_debug_engine_vp_0 = fp;
}

$ gcc -c warn.i -O1 -Wall
warn.i: In function ‘vm_debug_engine’:
warn.i:14:7: warning: implicit declaration of function ‘_setjmp’
[-Wimplicit-function-declaration]
   14 |   if (_setjmp(regs)) {
  |   ^~~
during GIMPLE pass: uninit
warn.i:8:1: internal compiler error: in find_var_cmp_const, at
gimple-predicate-analysis.cc:257
8 | vm_debug_engine() {
  | ^~~
0x84abb6 find_var_cmp_const
/home/marxin/Programming/gcc/gcc/gimple-predicate-analysis.cc:257
0x1c83ff2 uninit_analysis::overlap(gphi*, unsigned int, hash_set >*, predicate const&)
/home/marxin/Programming/gcc/gcc/gimple-predicate-analysis.cc:648
0x1c83b45 uninit_analysis::is_use_guarded(gimple*, basic_block_def*, gphi*,
unsigned int, hash_set >*)
/home/marxin/Programming/gcc/gcc/gimple-predicate-analysis.cc:2215
0x1c840ea uninit_analysis::is_use_guarded(gimple*, basic_block_def*, gphi*,
unsigned int)
/home/marxin/Programming/gcc/gcc/gimple-predicate-analysis.cc:2249
0x11188e7 find_uninit_use
/home/marxin/Programming/gcc/gcc/tree-ssa-uninit.cc:1234
0x111923e warn_uninitialized_phi
/home/marxin/Programming/gcc/gcc/tree-ssa-uninit.cc:1304
0x111923e execute_late_warn_uninitialized
/home/marxin/Programming/gcc/gcc/tree-ssa-uninit.cc:1425
0x111923e execute
/home/marxin/Programming/gcc/gcc/tree-ssa-uninit.cc:1442
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug tree-optimization/107937] [13 Regression] ICE in find_var_cmp_const, at gimple-predicate-analysis.cc:257 since r13-4408-gb628cad9e093f7a3

2022-11-30 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107937

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2022-12-01
 CC||marxin at gcc dot gnu.org,
   ||rguenth at gcc dot gnu.org
Summary|[13 Regression] ice in  |[13 Regression] ICE in
   |find_var_cmp_const, at  |find_var_cmp_const, at
   |gimple-predicate-analysis.c |gimple-predicate-analysis.c
   |c:257   |c:257 since
   ||r13-4408-gb628cad9e093f7a3
 Ever confirmed|0   |1

--- Comment #5 from Martin Liška  ---
Started with r13-4408-gb628cad9e093f7a3.