[PATCH] D124967: [SROA] Avoid postponing rewriting load/store by ignoring lifetime intrinsics in partition's promotability checking

Dmitry Vassiliev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 14:50:05 PDT 2022


slydiman created this revision.
slydiman added reviewers: nikic, lebedev.ri, serge-sans-paille.
slydiman added a project: LLVM.
Herald added a subscriber: hiraditya.
Herald added a project: All.
slydiman requested review of this revision.
Herald added a subscriber: llvm-commits.

Performance drift caused by generated ptx between slight different code calling flow.
This patch fixes a bug that generates unnecessary packing/unpacking structure code because of incorrectly handling lifetime intrinsic.

For example, a partition of an alloca may contain many slices:

  Partition [0, 4):
    Slice0: [0, 4) used by: load i32 addr;
    Slice1: [0, 4) used by: store i32 v, addr;
    Slice2: [0, 16) used by lifetime.start(16, addr);

When SROA determines if the partition can be promoted, `lifetime.start` is currently treated as a whole alloca load/store, so Slice0 and Slice1 cannot be promoted at this attempt, but the packing/unpacking code for Slice0 and Slice1 has been generated. After rewrite `lifetime.start/end` intrinsic, SROA tries again with Slice0 and Slice1 and finally promotes them, but redundant packing/unpacking code remaining in the IRs.

This patch changes promotability checking to ignore lifetime intrinsic (they will be rewritten to correct sizes later), so we can promote the real users (load/store) at the first attempt with optimal code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124967

Files:
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/test/Transforms/SROA/lifetime-intrinsic.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124967.427144.patch
Type: text/x-patch
Size: 7283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220504/12f0d5c6/attachment.bin>


More information about the llvm-commits mailing list