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

Richard Sandiford <rsandifo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rsandifo at gcc dot 
gnu.org

--- Comment #28 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
I'm back from holiday, so taking.

(In reply to Segher Boessenkool from comment #26)
> So, the one thing I really worry about a bit: will everything still work if
> we can lose some log_links in some (unusual) cases?  Or does anything rely on
> that never happening.
Yeah, that was my concern at first as well.  But I don't think the lack of a
log link enables any transformations that would otherwise not occur.  All
processing of log links seems to handle the absence of a link for a particular
register in a conservative way.

Even the initial set-up errs on the side of dropping links, since for example
create_log_links has:

             /* flow.c claimed:

                 We don't build a LOG_LINK for hard registers contained
                 in ASM_OPERANDs.  If these registers get replaced,
                 we might wind up changing the semantics of the insn,
                 even if reload can make what appear to be valid
                 assignments later.  */
              if (regno < FIRST_PSEUDO_REGISTER
                  && asm_noperands (PATTERN (use_insn)) >= 0)
                continue;

which excludes combinations by dropping log links, rather than during
try_combine.  And:

      /* If this register is being initialized using itself, and the
         register is uninitialized in this basic block, and there are
         no LOG_LINKS which set the register, then part of the
         register is uninitialized.  In that case we can't assume
         anything about the number of nonzero bits.

         ??? We could do better if we checked this in
         reg_{nonzero_bits,num_sign_bit_copies}_for_combine.  Then we
         could avoid making assumptions about the insn which initially
         sets the register, while still using the information in other
         insns.  We would have to be careful to check every insn
         involved in the combination.  */

      if (insn
          && reg_referenced_p (x, PATTERN (insn))
          && !REGNO_REG_SET_P (DF_LR_IN (BLOCK_FOR_INSN (insn)),
                               REGNO (x)))
        {
          struct insn_link *link;

          FOR_EACH_LOG_LINK (link, insn)
            if (dead_or_set_p (link->insn, x))
              break;
          if (!link)
            {
              rsp->nonzero_bits = GET_MODE_MASK (mode);
              rsp->sign_bit_copies = 1;
              return;
            }
        }

treats the lack of a log link is a possible sign of uninitialised data, but
that would be a missed optimisation rather than a correctness issue.

Reply via email to