[all-commits] [llvm/llvm-project] f13d25: [TBAA] Only clear TBAAStruct if field can be extra...

Florian Hahn via All-commits all-commits at lists.llvm.org
Fri Feb 9 10:16:03 PST 2024


  Branch: refs/heads/users/fhahn/sroa-use-tbaa-for-matching-field-access
  Home:   https://github.com/llvm/llvm-project
  Commit: f13d25563743926042f132d995a443b5c6f1d382
      https://github.com/llvm/llvm-project/commit/f13d25563743926042f132d995a443b5c6f1d382
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2024-02-09 (Fri, 09 Feb 2024)

  Changed paths:
    M llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
    M llvm/test/Transforms/InstCombine/struct-assign-tbaa.ll

  Log Message:
  -----------
  [TBAA] Only clear TBAAStruct if field can be extracted.

Retain TBAAStruct if we fail to match the access to a single field. All
users at the moment use this when using the full size of the original
access. SROA also retains the original TBAAStruct when accessing parts
at offset 0.

Motivation for this and follow-on patches is to improve codegen for
libc++, where using memcpy limits optimizations, like vectorization for
code iteration over std::vector<std::complex<float>>:
https://godbolt.org/z/f3vqYos3c


  Commit: 6da0fd5686500fff39410ff9da61cb3f91f4f187
      https://github.com/llvm/llvm-project/commit/6da0fd5686500fff39410ff9da61cb3f91f4f187
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2024-02-09 (Fri, 09 Feb 2024)

  Changed paths:
    M llvm/include/llvm/IR/Metadata.h
    M llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
    M llvm/lib/Transforms/Scalar/SROA.cpp
    M llvm/test/Transforms/SROA/tbaa-struct2.ll
    M llvm/test/Transforms/SROA/tbaa-struct3.ll

  Log Message:
  -----------
  [SROA] Use !tbaa instead of !tbaa.struct if op matches field.

If a split memory access introduced by SROA accesses precisely a single
field of the original operation's !tbaa.struct, use the !tbaa tag for
the accessed field directly instead of the full !tbaa.struct.

InstCombine already had a similar logic.

Motivation for this and follow-on patches is to improve codegen for
libc++, where using memcpy limits optimizations, like vectorization for
code iteration over std::vector<std::complex<float>>:
https://godbolt.org/z/f3vqYos3c

Depends on https://github.com/llvm/llvm-project/pull/81285.


Compare: https://github.com/llvm/llvm-project/compare/f13d25563743%5E...6da0fd568650


More information about the All-commits mailing list