http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55481



Richard Biener <rguenth at gcc dot gnu.org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

                 CC|                            |rakdver at gcc dot gnu.org



--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> 2012-11-28 
15:38:46 UTC ---

We have



@@ -15,22 +15,11 @@

   (scalar = result_11)

 (get_scalar_evolution 

   (scalar = result_11)

-  (scalar_evolution = result_11))

+  (scalar_evolution = (signed char) {0, +, 31}_1))



that isn't wrong.  But IVOPTs happily uses STRIP_NOPs which also strips

sign-conversions.  simple_iv returns true for result_11 in



  signed char result;



  <bb 3>:

  # result_11 = PHI <result_5(4), 0(2)>

  # ivtmp_10 = PHI <ivtmp_9(4), 13(2)>

  tem_3 = (int) result_11;

  tem_4 = tem_3 + 31;

  result_5 = (signed char) tem_4;

  ivtmp_9 = ivtmp_10 - 1;

  if (ivtmp_9 != 0)

    goto <bb 4>;

  else

    goto <bb 5>;



  <bb 4>:

  goto <bb 3>;



now, but iv->no_overflow is false (and IVOPTs nowhere uses that flag ...).



I can fix this for example with



Index: tree-ssa-loop-ivopts.c

===================================================================

--- tree-ssa-loop-ivopts.c      (revision 193887)

+++ tree-ssa-loop-ivopts.c      (working copy)

@@ -982,6 +982,9 @@ determine_biv_step (gimple phi)

   if (!simple_iv (loop, loop, name, &iv, true))

     return NULL_TREE;



+  if (!iv.no_overflow)

+    return NULL_TREE;

+

   return integer_zerop (iv.step) ? NULL_TREE : iv.step;

 }



but I'm not sure what invariants should hold for BIVs and if the overflow

check should happen in a different place instead.  Zdenek?

Reply via email to