https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104196

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The problem looks like a latent bug in reassoc1.
Before:
if (a.0_1 < 0)
    goto <bb 4>; [41.00%]
  else
    goto <bb 5>; [59.00%]

  <bb 4> [local count: 440234144]:
  # RANGE [-2147483646, 1]
  c_6 = -2147483647 - a.0_1;
  _9 = a.0_1 != -2147479551;
  _4 = c_6 == 1;
  _3 = _4 | _9;
  if (_3 != 0)
    goto <bb 5>; [60.23%]
  else
    goto <bb 3>; [39.77%]

  <bb 5> [local count: 118111600]:
  if (a.0_1 <= 5)
    goto <bb 6>; [0.00%]
  else
    goto <bb 7>; [100.00%]

Which is correct and the overflow only happens in bb 4 which is never reached
here as a == 6.

After reassoc1 we have:
  c_6 = -2147483647 - a.0_1;
  _10 = a.0_1 != -2147479551;
  _9 = a.0_1 != -2147479551;
  _4 = c_6 == 1;
  _12 = _4 | _10;
  if (_12 != 0)
    goto <bb 4>; [60.23%]
  else
    goto <bb 3>; [39.77%]

  <bb 4> [local count: 118111600]:
  if (a.0_1 <= 5)
    goto <bb 5>; [0.00%]
  else
    goto <bb 6>; [100.00%]

Which is totally bogus and I suspect it is because we had that range on c_6
assignment.


>From -fdump-tree-reassoc1-all:

Matching expression match.pd:2080, generic-match.cc:693
Matching expression match.pd:2083, generic-match.cc:753
Matching expression match.pd:2090, generic-match.cc:776
Optimizing range tests a.0_1 +[-2147479551, -2147479551] and -[0, ]
 into a.0_1 == -2147479551
Matching expression match.pd:2080, gimple-match.cc:819
Matching expression match.pd:2083, gimple-match.cc:892
Matching expression match.pd:2090, gimple-match.cc:952

Reply via email to