[PATCH] D69998: [MacroFusion] Create the missing artificial edges if there are more than 2 SU fused.

Qing Shan Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 02:25:10 PST 2019


steven.zhang created this revision.
steven.zhang added reviewers: jsji, nemanjai, hfinkel, fhahn, evandro, MatzeB, PowerPC.
Herald added subscribers: wuzish, hiraditya, nhaehnle, jvesely, arsenm.
Herald added a project: LLVM.

For now, llvm MacroFusion would fuse the adjacent instructions no matter if it has been fused before. However, we miss to create some edges that cause problem. And most target as far as I see, only support the back-to-back macro-fusion. The more than 2 SU fusion will create extra dependency that hurt the scheduler. We should leave it to the target to make the decision.

Assume that we have the code:

  int foo(int a, int b, int c, int d) {
    return a + b + c +d;
  }

And ADD and ADD are a fusion pair. And this is the Dependency graph.

  +------+       +------+       +------+       +------+
  |  A   |       |  B   |       |  C   |       |  D   |
  +--+--++       +---+--+       +--+---+       +--+---+
     ^  ^            ^  ^          ^              ^
     |  |            |  |          |              |
     |  |            |  |New1      +--------------+
     |  |            |  |          |
     |  |            |  |       +--+---+
     |  |New2        |  +-------+ ADD1 |
     |  |            |          +--+---+
     |  |            |    Fuse     ^
     |  |            +-------------+
     |  +------------+
     |               |
     |   Fuse     +--+---+
     +----------->+ ADD2 |
     |            +------+
  +--+---+
  | ADD3 |
  +------+

When ADD1 and ADD2 are fused, we will create an artificial edge New1 to make sure that, B is scheduled before ADD1. And when ADD3 and ADD2 are fused,
another artificial edge New2 is created to make sure that, A is scheduled before ADD2. However, this is NOT enough. We need to create another artificial edge from ADD1 to A to make sure that, A is scheduled before ADD1 also.


https://reviews.llvm.org/D69998

Files:
  llvm/include/llvm/CodeGen/MacroFusion.h
  llvm/lib/CodeGen/MacroFusion.cpp
  llvm/lib/Target/AArch64/AArch64MacroFusion.cpp
  llvm/lib/Target/AMDGPU/AMDGPUMacroFusion.cpp
  llvm/lib/Target/ARM/ARMMacroFusion.cpp
  llvm/lib/Target/X86/X86MacroFusion.cpp
  llvm/test/CodeGen/AArch64/macro-fusion-verify.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69998.228375.patch
Type: text/x-patch
Size: 10209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191108/2e173270/attachment.bin>


More information about the llvm-commits mailing list