The following fixes a fallout of fixing PR55862 - the fix for it
merely papered over the issue that we inconsistently prune
expressions in clean ().  Fixing that allows us to revert the
original PR55862 fix and thus fix PR55888.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2013-01-07  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/55888
        PR tree-optimization/55862
        * tree-ssa-pre.c (phi_translate_1): Revert previous change.
        (valid_in_sets): Check if a NAME has a leader in AVAIL_OUT,
        not if it is contained therein.

        * gcc.dg/torture/pr55888.c: New testcase.

Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c  (revision 194964)
--- gcc/tree-ssa-pre.c  (working copy)
*************** phi_translate_1 (pre_expr expr, bitmap_s
*** 1729,1738 ****
            edge e = find_edge (pred, gimple_bb (def_stmt));
            tree def = PHI_ARG_DEF (def_stmt, e->dest_idx);
  
-           /* Valueize it.  */
-           if (TREE_CODE (def) == SSA_NAME)
-             def = VN_INFO (def)->valnum;
- 
            /* Handle constant. */
            if (is_gimple_min_invariant (def))
              return get_or_alloc_expr_for_constant (def);
--- 1729,1734 ----
*************** valid_in_sets (bitmap_set_t set1, bitmap
*** 1978,1984 ****
    switch (expr->kind)
      {
      case NAME:
!       return bitmap_set_contains_expr (AVAIL_OUT (block), expr);
      case NARY:
        {
        unsigned int i;
--- 1974,1981 ----
    switch (expr->kind)
      {
      case NAME:
!       return bitmap_find_leader (AVAIL_OUT (block),
!                                get_expr_value_id (expr)) != NULL;
      case NARY:
        {
        unsigned int i;
Index: gcc/testsuite/gcc.dg/torture/pr55888.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr55888.c      (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr55888.c      (working copy)
***************
*** 0 ****
--- 1,116 ----
+ /* { dg-do compile } */
+ 
+ typedef unsigned _GCC_ATTR_ALIGN_u32t;
+ typedef _GCC_ATTR_ALIGN_u32t _Uint32t __attribute__ ((__aligned__ (4)));
+ typedef unsigned int _GCC_ATTR_ALIGN_u8t __attribute__ ((__mode__ (__QI__)));
+ typedef _GCC_ATTR_ALIGN_u8t _Uint8t __attribute__ ((__aligned__ (1)));
+ typedef unsigned _Sizet;
+ typedef _Sizet size_t;
+ typedef _Uint8t uint8_t;
+ typedef _Uint32t uint32_t;
+ typedef enum
+ {
+   PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_LABEL_OPTIONAL,
+     PROTOBUF_C_LABEL_REPEATED
+ }
+ ProtobufCLabel;
+ typedef enum
+ {
+   PROTOBUF_C_TYPE_INT32, PROTOBUF_C_TYPE_SINT32, PROTOBUF_C_TYPE_SFIXED32,
+     PROTOBUF_C_TYPE_INT64, PROTOBUF_C_TYPE_SINT64, PROTOBUF_C_TYPE_SFIXED64,
+     PROTOBUF_C_TYPE_UINT32, PROTOBUF_C_TYPE_FIXED32, PROTOBUF_C_TYPE_UINT64,
+     PROTOBUF_C_TYPE_FIXED64, PROTOBUF_C_TYPE_FLOAT, PROTOBUF_C_TYPE_DOUBLE,
+     PROTOBUF_C_TYPE_BOOL, PROTOBUF_C_TYPE_ENUM, PROTOBUF_C_TYPE_STRING,
+     PROTOBUF_C_TYPE_BYTES, PROTOBUF_C_TYPE_MESSAGE,
+ }
+ ProtobufCType;
+ typedef struct _ProtobufCBinaryData ProtobufCBinaryData;
+ struct _ProtobufCBinaryData
+ {
+   size_t len;
+ };
+ typedef struct _ProtobufCMessageDescriptor ProtobufCMessageDescriptor;
+ typedef struct _ProtobufCFieldDescriptor ProtobufCFieldDescriptor;
+ typedef struct _ProtobufCMessage ProtobufCMessage;
+ struct _ProtobufCFieldDescriptor
+ {
+   uint32_t id;
+   ProtobufCLabel label;
+   ProtobufCType type;
+   unsigned offset;
+ };
+ struct _ProtobufCMessageDescriptor
+ {
+   unsigned n_fields;
+   const ProtobufCFieldDescriptor *fields;
+ };
+ struct _ProtobufCMessage
+ {
+   const ProtobufCMessageDescriptor *descriptor;
+ };
+ typedef enum
+ {
+   PROTOBUF_C_WIRE_TYPE_VARINT, PROTOBUF_C_WIRE_TYPE_64BIT,
+     PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED, PROTOBUF_C_WIRE_TYPE_START_GROUP,
+     PROTOBUF_C_WIRE_TYPE_END_GROUP, PROTOBUF_C_WIRE_TYPE_32BIT
+ }
+ ProtobufCWireType;
+ static inline size_t
+ uint32_pack (uint32_t value, uint8_t * out)
+ {
+   unsigned rv = 0;
+   if (value >= 0x80)
+     {
+       if (value >= 0x80)
+       {
+         value >>= 7;
+       }
+     }
+   out[rv++] = value;
+ }
+ 
+ static inline size_t
+ binary_data_pack (const ProtobufCBinaryData * bd, uint8_t * out)
+ {
+   size_t len = bd->len;
+   size_t rv = uint32_pack (len, out);
+   return rv + len;
+ }
+ 
+ static size_t
+ required_field_pack (const ProtobufCFieldDescriptor * field,
+                    const void *member, uint8_t * out)
+ {
+   size_t rv = tag_pack (field->id, out);
+   switch (field->type)
+     {
+     case PROTOBUF_C_TYPE_BYTES:
+       {
+       const ProtobufCBinaryData *bd =
+         ((const ProtobufCBinaryData *) member);
+       out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
+       return rv + binary_data_pack (bd, out + rv);
+       }
+     case PROTOBUF_C_TYPE_MESSAGE:
+       {
+       out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
+       return rv +
+         prefixed_message_pack (*(ProtobufCMessage * const *) member,
+                                out + rv);
+       }
+     }
+ }
+ 
+ size_t
+ protobuf_c_message_pack (const ProtobufCMessage * message, uint8_t * out)
+ {
+   unsigned i;
+   size_t rv = 0;
+   for (i = 0; i < message->descriptor->n_fields; i++)
+     {
+       const ProtobufCFieldDescriptor *field = message->descriptor->fields + i;
+       const void *member = ((const char *) message) + field->offset;
+       if (field->label == PROTOBUF_C_LABEL_REQUIRED)
+       rv += required_field_pack (field, member, out + rv);
+     }
+ }

Reply via email to