[PATCH] D94641: [AArch64][GlobalISel] Use wzr/xzr for FP stores of zero

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 13 16:26:11 PST 2021


paquette created this revision.
paquette added a reviewer: aemerson.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls, rovka.
paquette requested review of this revision.
Herald added a project: LLVM.

In situations like the example below, GlobalISel produces an unnecessary fmov from wzr.

https://godbolt.org/z/Y45W8T

  define void @test(float* %ptr, float %x) {
      %cmp = fcmp une float undef, 0.000000e+00
      br i1 %cmp, label %a, label %b
  a:
      %gep = getelementptr inbounds float, float* %ptr, i32 1
      store float 0.000000e+00, float* %gep, align 4
      ret void
  b:
      ret void
  }

In a lot of cases, `matchFConstantToConstant` in the pre-legalizer combiner handles this sort of thing.

However, that combine only works when all users of a G_FCONSTANT are stores. In this case, we have a G_FCMP which also uses the G_FCONSTANT.

This patch adds a post-legalization (lowering) combine which looks for G_STORES which store a positive 0. If such a store is found, and we know it can use wzr/xzr, then it's updated to use a G_CONSTANT 0.

During selection, the constant 0 + store will be selected to a store of wzr/xzr.

This is a 0.1% code size improvement at -Os for CTMark/mafft/pairlocalalign. There are minor code size improvements in other CTMark tests as well.


https://reviews.llvm.org/D94641

Files:
  llvm/lib/Target/AArch64/AArch64Combine.td
  llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-lowering-zero-store.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94641.316533.patch
Type: text/x-patch
Size: 5418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210114/79ada2b9/attachment.bin>


More information about the llvm-commits mailing list