[all-commits] [llvm/llvm-project] 087cd5: [SelectionDAG] Precommit EmitCopyFromReg test for ...

Jay Foad via All-commits all-commits at lists.llvm.org
Wed Dec 21 02:47:30 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 087cd5e5d16759f41b0701545b6ae11c95cf1fae
      https://github.com/llvm/llvm-project/commit/087cd5e5d16759f41b0701545b6ae11c95cf1fae
  Author: Jay Foad <jay.foad at amd.com>
  Date:   2022-12-21 (Wed, 21 Dec 2022)

  Changed paths:
    A llvm/test/CodeGen/AMDGPU/bug-sdag-emitcopyfromreg.ll

  Log Message:
  -----------
  [SelectionDAG] Precommit EmitCopyFromReg test for D140417


  Commit: e73b35699be0166d2de8cbb7cb6ac544a3e63f5f
      https://github.com/llvm/llvm-project/commit/e73b35699be0166d2de8cbb7cb6ac544a3e63f5f
  Author: Jay Foad <jay.foad at amd.com>
  Date:   2022-12-21 (Wed, 21 Dec 2022)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
    M llvm/lib/CodeGen/SelectionDAG/InstrEmitter.h
    M llvm/test/CodeGen/AMDGPU/bug-sdag-emitcopyfromreg.ll

  Log Message:
  -----------
  [SelectionDAG] Fix EmitCopyFromReg for cloned nodes

Change EmitCopyFromReg to check all users of cloned nodes (as well as
non-cloned nodes) instead of assuming that they all copy the defined
value back to the same physical register.

This partially reverts 968e2e7b3db1 (svn r62356) which claimed:

  CreateVirtualRegisters does trivial copy coalescing. If a node def is
  used by a single CopyToReg, it reuses the virtual register assigned to
  the CopyToReg. This won't work for SDNode that is a clone or is itself
  cloned. Disable this optimization for those nodes or it can end up
  with non-SSA machine instructions.

This is true for CreateVirtualRegisters but r62356 also updated
EmitCopyFromReg where it is not true. Firstly EmitCopyFromReg only
coalesces physical register copies, so the concern about SSA form does
not apply. Secondly making the loop over users in EmitCopyFromReg
conditional on `!IsClone && !IsCloned` breaks the handling of cloned
nodes, because it leaves MatchReg set to true by default, so it assumes
that all users will copy the defined value back to the same physical
register instead of actually checking.

Differential Revision: https://reviews.llvm.org/D140417


Compare: https://github.com/llvm/llvm-project/compare/673ce562910a...e73b35699be0


More information about the All-commits mailing list