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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
#4  0x000000000189c86e in ipcp_vr_lattice::meet_with_1 (this=0x280a780, 
    other_vr=0x7ffff69a3e88) at /space/rguenther/src/svn/trunk/gcc/ipa-cp.c:987
987       vrp_meet (&m_vr, other_vr);
(gdb) l
982         return false;
983
984       if (other_vr->type == VR_VARYING)
985         return set_to_bottom ();
986
987       vrp_meet (&m_vr, other_vr);
988       if (type != m_vr.type
989           || min != m_vr.min
990           || max != m_vr.max)
991         return true;
(gdb) p debug_value_range(other_vr)
[-25536(OVF), -25536(OVF)]

those overflow bits are bogus.  Ultimatively comes from the jump function VR:

  else if (jfunc->type == IPA_JF_CONST)
    {
      tree val = ipa_get_jf_constant (jfunc);
      if (TREE_CODE (val) == INTEGER_CST)
        {
          jfunc->vr_known = true;
          jfunc->m_vr.type = VR_RANGE;
          jfunc->m_vr.min = val;
          jfunc->m_vr.max = val;
          return dest_lat->meet_with (&jfunc->m_vr);

and basically means that IPA_JF_CONST should be stripping overflow flags.

The overflow flag is ultimatively introduced at FRE1:

main ()
{
  int c$0;
  int c[1];

  <bb 2>:
  fn1 (-25536(OVF));

Setting value number of _1 to 40000 (changed)
Value numbering _2 stmt = _2 = (short int) _1;
Match-and-simplified (short int) _1 to -25536(OVF)
RHS (short int) _1 simplified to -25536(OVF)


I have a patch to fix this particular source of overflow flags but given the
assert VRP routine users should make sure to strip overflow themselves.


Index: gcc/gimple-match-head.c
===================================================================
--- gcc/gimple-match-head.c     (revision 240342)
+++ gcc/gimple-match-head.c     (working copy)
@@ -89,6 +89,8 @@ gimple_resimplify1 (gimple_seq *seq,
       if (tem != NULL_TREE
          && CONSTANT_CLASS_P (tem))
        {
+         if (TREE_OVERFLOW_P (tem))
+           tem = drop_tree_overflow (tem);
          res_ops[0] = tem;
          res_ops[1] = NULL_TREE;
          res_ops[2] = NULL_TREE;
@@ -134,6 +136,8 @@ gimple_resimplify2 (gimple_seq *seq,
       if (tem != NULL_TREE
          && CONSTANT_CLASS_P (tem))
        {
+         if (TREE_OVERFLOW_P (tem))
+           tem = drop_tree_overflow (tem);
          res_ops[0] = tem;
          res_ops[1] = NULL_TREE;
          res_ops[2] = NULL_TREE;
@@ -194,6 +198,8 @@ gimple_resimplify3 (gimple_seq *seq,
       if (tem != NULL_TREE
          && CONSTANT_CLASS_P (tem))
        {
+         if (TREE_OVERFLOW_P (tem))
+           tem = drop_tree_overflow (tem);
          res_ops[0] = tem;
          res_ops[1] = NULL_TREE;
          res_ops[2] = NULL_TREE;

Reply via email to