[PATCH] D114832: [SROA] For a type of alloca access, skip scalarization in SROA pass; the goal is to save useless operations to coalesce values.

Mingming Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 30 16:55:39 PST 2021


luna created this revision.
Herald added a subscriber: hiraditya.
luna retitled this revision from "[SROA] For a specialized case, skip scalarization in SROA pass; the goal is to save useless operations to coalesce values. Before this change, coalesce instructions are difficult to clean up, and prevent the tail call generation (see test case..." to "[SROA] For a type of alloca access, skip scalarization in SROA pass; the goal is to save useless operations to coalesce values. ".
luna edited the summary of this revision.
luna added reviewers: Carrot, efriedma, aeubanks.
luna added a subscriber: davidxl.
luna published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Before this change, coalesce instructions are difficult to clean up, and prevent the tail call generation (see test case `test_struct_of_two_int` in llvm/test/Transforms/SROA/alloca-struct.ll)

Change SROA pass so a structure type won't be scalarized to smaller allocations (i.e., remain unchanged) in the following conditions

1. If it doesn't have scalar access

or

2. If the scalar stores will essentially make the struct a constant (i.e., all individual fields are constant values).

This change adds additional analysis information about usages, and mark all slices of an alloca as `unsplittable` if all conditions are true:

1. The alloca doesn't have a) scalar load b) non constant scalar store c) uncovered access type (e.g., memcpy, memset, etc)
2. In each basic block, the constant stores cover all bytes (i.e., the allocated type could be regarded as a constant in that basic block)

The change preserves original slice-split logic if there are scalar access, or if analysis information isn't sufficient to prevent scalarization.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114832

Files:
  llvm/include/llvm/Transforms/Scalar/SROA.h
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/test/Transforms/SROA/alloca-struct.ll
  llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll
  llvm/test/Transforms/SROA/basictest.ll
  llvm/test/Transforms/SROA/big-endian.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114832.390861.patch
Type: text/x-patch
Size: 51720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211201/0c68b495/attachment.bin>


More information about the llvm-commits mailing list