On Thu, 22 Mar 2007, Mark Mitchell wrote:

> Joseph, would you please take a look at PR 31136?  Andrew believes this
> to be a front-end bug.

I don't think this is a front-end bug.

I applied the patch below to make the dumps give more meaningful 
information than <unnamed type>.  The format of output is the same as 
used by the C pretty-printer.  (OK to commit this patch to mainline 
subject to the usual testing?)  With it, the .gimple dump is:

main ()
{
  <unnamed-unsigned:6> D.1530;
  <unnamed-unsigned:4> D.1531;
  <unnamed-unsigned:4> D.1532;
  <unnamed-unsigned:6> D.1533;
  int D.1534;
  short unsigned int D.1535;
  short unsigned int D.1536;

  s.b6 = 31;
  D.1530 = s.b6;
  D.1531 = (<unnamed-unsigned:4>) D.1530;
  s.b4 = D.1531;
  D.1532 = s.b4;
  D.1533 = (<unnamed-unsigned:6>) D.1532;
  s.b6 = D.1533;
  D.1535 = BIT_FIELD_REF <s, 16, 0>;
  D.1536 = D.1535 & 1008;
  D.1534 = D.1536 != 240;
  return D.1534;
}

As far as I can see, this has all the required conversions.  The 
conversions seem correct as of the .ccp dump, so I think the problem is in 
the FRE pass as identified in the original bug report.

Specifically, I blame use of STRIP_NOPS or STRIP_SIGN_NOPS somewhere in 
the optimizers, removing a conversion that preserves the mode when such 
conversion is necessary to truncate to a narrower bit-field type.  If I 
make those macros require the precision to be unchanged then the testcase 
passes.  But such a change clearly needs more testing, and it should 
probably be more conservative (conversions to a wider precision should be 
OK to remove as well as those to the same precision, except when they 
convert signed to unsigned).  If this is the cause, the problem is 
probably present in 4.1 as well, though whether it can be triggered 
depends on how much the tree optimizers do with conversions to bit-field 
types (which in normal code only arise through stores to bit-fields).

Note, I haven't tested at all for C++, and the bug is described as for 
both C and C++.

Index: tree-pretty-print.c
===================================================================
--- tree-pretty-print.c (revision 123147)
+++ tree-pretty-print.c (working copy)
@@ -539,6 +539,14 @@
                dump_generic_node (buffer, TREE_TYPE (node), 
                                   spc, flags, false);
              }
+           else if (TREE_CODE (node) == INTEGER_TYPE)
+             {
+               pp_string (buffer, (TYPE_UNSIGNED (node)
+                                   ? "<unnamed-unsigned:"
+                                   : "<unnamed-signed:"));
+               pp_decimal_int (buffer, TYPE_PRECISION (node));
+               pp_string (buffer, ">");
+             }
            else
               pp_string (buffer, "<unnamed type>");
          }

-- 
Joseph S. Myers
[EMAIL PROTECTED]

Reply via email to