[Bug tree-optimization/10520] induction variable analysis not used to eliminate comparisons

2023-02-17 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10520

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=108841

--- Comment #7 from Andrew Pinski  ---
(In reply to Andrew Pinski from comment #6)
> Also? To simplify things a little more?

I filed PR 108841 for that.

[Bug tree-optimization/10520] induction variable analysis not used to eliminate comparisons

2022-01-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10520

--- Comment #6 from Andrew Pinski  ---
Hmm, shouldn't we convert:
  _24 = MAX_EXPR ;
  if (_24 < _tmp0_27(D))
goto ; [94.50%]
  else
goto ; [5.50%]

   [local count: 906139990]:
  _25 = MAX_EXPR ;
  if (_25 < _tmp0_27(D))
goto ; [94.50%]
  else
goto ; [5.50%]
Which is:

if (MAX_EXPR  < _tmp0_27 && MAX_EXPR  <
_tmp0_27) goto 3 else goto 5

Into:
if (MAX_EXPR, MAX_EXPR  > <
_tmp0_27)  goto 3 else goto 5

Also? To simplify things a little more?

[Bug tree-optimization/10520] induction variable analysis not used to eliminate comparisons

2022-01-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10520

--- Comment #5 from Andrew Pinski  ---
Here is the current IR at optimized:
   [local count: 958878296]:
  # n_in_42 = PHI 
  # n_out_43 = PHI 
  # n_in1_44 = PHI 
  # n_out1_45 = PHI 
  n_in.0_1 = (int) n_in_42;
  _3 = n_in.0_1 w* 4;
  _4 = buf_fast_28(D) + _3;
  n_out.1_5 = (int) n_out_43;
  _7 = n_out.1_5 w* 4;
  _8 = buf_fast_28(D) + _7;
  _9 = *_4;
  *_8 = _9;
  n_in1.2_10 = (int) n_in1_44;
  _12 = n_in1.2_10 w* 4;
  _13 = buf_fast_28(D) + _12;
  n_out1.3_14 = (int) n_out1_45;
  _16 = n_out1.3_14 w* 4;
  _17 = buf_fast_28(D) + _16;
  _18 = *_13;
  *_17 = _18;
  n_in_31 = n_in_42 + 4;
  n_out_32 = n_out_43 + 2;
  n_in1_33 = n_in1_44 + 4;
  n_out1_34 = n_out1_45 + 2;
  _24 = MAX_EXPR ;
  if (_24 < _tmp0_27(D))
goto ; [94.50%]
  else
goto ; [5.50%]

   [local count: 906139990]:
  _25 = MAX_EXPR ;
  if (_25 < _tmp0_27(D))
goto ; [94.50%]
  else
goto ; [5.50%]


We should figure out that:
  _24 = MAX_EXPR ;

Is just as n_in_31 is being incremented by 4 each time through the loop while
n_out_32 only by 2
_24 = n_in_31

And:
  _25 = MAX_EXPR ;

Is just (same logic as above)
_25 = n_in1_33

And then we have:
  if (n_in_31 < _tmp0_27(D))
goto ; [94.50%]
  else
goto ; [5.50%]

   [local count: 906139990]:
  if (n_in1_33 < _tmp0_27(D))
goto ; [94.50%]
  else
goto ; [5.50%]

Where n_in1_33 = n_in_31+1
There for we should reduce it to just:
   [local count: 906139990]:
  if (n_in1_33 < _tmp0_27(D))
goto ; [94.50%]
  else
goto ; [5.50%]

(hopefully I did this correctly).
Of course this depends on if they are not going to be overflowed  Which we
know they won't because they are being used for pointer accesses.

[Bug tree-optimization/10520] induction variable analysis not used to eliminate comparisons

2014-03-13 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10520

--- Comment #4 from Richard Biener rguenth at gcc dot gnu.org ---
First of all number-of-iteration analysis would need to figure out that
the vars don't overflow ... (thus that the loop terminates).  It cannot
even compute the number of iterations symbolically.