[all-commits] [llvm/llvm-project] 0f0fd3: [AArch64][GlobalISel] Introduce a new post-isel op...

AE via All-commits all-commits at lists.llvm.org
Fri Oct 23 10:18:58 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 0f0fd383b487e004fd616ac941307422bd09c261
      https://github.com/llvm/llvm-project/commit/0f0fd383b487e004fd616ac941307422bd09c261
  Author: Amara Emerson <amara at apple.com>
  Date:   2020-10-23 (Fri, 23 Oct 2020)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64.h
    M llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
    M llvm/lib/Target/AArch64/CMakeLists.txt
    A llvm/lib/Target/AArch64/GISel/AArch64PostSelectOptimize.cpp
    M llvm/test/CodeGen/AArch64/GlobalISel/gisel-commandline-option.ll
    A llvm/test/CodeGen/AArch64/GlobalISel/postselectopt-dead-cc-defs-in-fcmp.mir
    M llvm/test/CodeGen/AArch64/addsub-shifted.ll
    M llvm/test/CodeGen/AArch64/addsub_ext.ll
    M llvm/utils/gn/secondary/llvm/lib/Target/AArch64/BUILD.gn

  Log Message:
  -----------
  [AArch64][GlobalISel] Introduce a new post-isel optimization pass.

There are two optimizations here:

1. Consider the following code:
 FCMPSrr %0, %1, implicit-def $nzcv
 %sel1:gpr32 = CSELWr %_, %_, 12, implicit $nzcv
 %sub:gpr32 = SUBSWrr %_, %_, implicit-def $nzcv
 FCMPSrr %0, %1, implicit-def $nzcv
 %sel2:gpr32 = CSELWr %_, %_, 12, implicit $nzcv
This kind of code where we have 2 FCMPs each feeding a CSEL can happen
when we have a single IR fcmp being used by two selects. During selection,
to ensure that there can be no clobbering of nzcv between the fcmp and the
csel, we have to generate an fcmp immediately before each csel is
selected.

However, often we can essentially CSE these together later in MachineCSE.
This doesn't work though if there are unrelated flag-setting instructions
in between the two FCMPs. In this case, the SUBS defines NZCV
but it doesn't have any users, being overwritten by the second FCMP.

Our solution here is to try to convert flag setting operations between
a interval of identical FCMPs, so that CSE will be able to eliminate one.

2. SelectionDAG imported patterns for arithmetic ops currently select the
flag-setting ops for CSE reasons, and add the implicit-def $nzcv operand
to those instructions. However if those impdef operands are not marked as
dead, the peephole optimizations are not able to optimize them into non-flag
setting variants. The optimization here is to find these dead imp-defs and
mark them as such.

This pass is only enabled when optimizations are enabled.

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




More information about the All-commits mailing list