[Bug tree-optimization/101768] -Wmaybe-uninitialized false alarm with non local variables in some cases

2021-08-03 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101768

--- Comment #3 from Andrew Pinski  ---
[AFTER NORMALIZATION -- [DEF]:
 (.NOT.) ct.0_1 == 1


[AFTER NORMALIZATION -- [DEF]:
offset_width_13 = PHI 
is guarded by :

 (.NOT.) arg_10 != 0 (.AND.) arg_16 != 0 (.AND.) ct.0_1 == 1
(.OR.)
 (.NOT.) arg_16 != 0 (.AND.) ct.0_1 == 1


[AFTER NORMALIZATION -- [USE]:
foo (offset_width_13);
is guarded by :

prephitmp_5 == 1

Uninit did not look up the chain for prephitmp_5 to see:
  # prephitmp_5 = PHI 


  foo (offset_width_13);
  pretmp_6 = ct;

[Bug tree-optimization/101768] -Wmaybe-uninitialized false alarm with non local variables in some cases

2021-08-03 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101768

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
   Keywords||diagnostic
   Last reconfirmed||2021-08-03
Summary|-Wmaybe-uninitialized false |-Wmaybe-uninitialized false
   |alarm with 'switch' instead |alarm with non local
   |of 'if' |variables in some cases

--- Comment #2 from Andrew Pinski  ---
here is a reduced testcase:
int ct;
void foo (int);

int
cmp (int arg)
{
  int differing = 0;
  int offset_width;

  if (ct == 1)
{
  offset_width = 1;
  for (offset_width = 1; (arg /= 10) != 0; offset_width++)
;
}
  do {
  if (ct == 1) {
foo (offset_width);
differing--;
  }
}  while (differing <= 0);

  return !!differing;
}

GCC does not figure out once ct == 1, and foo is called, it will either become
ct == 1 which is fine or never be ct == 1 again.