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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The problem is that gimple_fold_indirect_ref uses STRIP_NOPS and then has
  /* *(foo *)fooarrptr => (*fooarrptr)[0] */
  if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE
      && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (subtype)))) == INTEGER_CST
      && useless_type_conversion_p (type, TREE_TYPE (TREE_TYPE (subtype))))
    {
      tree type_domain;
      tree min_val = size_zero_node;
      tree osub = sub;
      sub = gimple_fold_indirect_ref (sub);
      if (! sub)
        sub = build1 (INDIRECT_REF, TREE_TYPE (subtype), osub);
      type_domain = TYPE_DOMAIN (TREE_TYPE (sub));
      if (type_domain && TYPE_MIN_VALUE (type_domain))
        min_val = TYPE_MIN_VALUE (type_domain);
      if (TREE_CODE (min_val) == INTEGER_CST)
        return build4 (ARRAY_REF, type, sub, min_val, NULL_TREE, NULL_TREE);
    }
Without the
#if GENERIC
(simplify
  (pointer_plus (convert:s (pointer_plus:s @0 @1)) @3)
  (convert:type (pointer_plus @0 (plus @1 @3))))
#endif
rule, this doesn't trigger as ARRAY_TYPE is just the type of the inner
POINTER_PLUS and there is the outer one which has int * type.
So, wonder whether I shouldn't change the rule to
  (pointer_plus (convert:type @0) (plus @1 #3))))
instead.

Reply via email to