[all-commits] [llvm/llvm-project] eb197e: [Transforms] Add lit test for instcombine on load ...

Jannik Silvanus via All-commits all-commits at lists.llvm.org
Mon Jan 23 04:26:03 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eb197e3ea670ee0c573d95a0033327a213656357
      https://github.com/llvm/llvm-project/commit/eb197e3ea670ee0c573d95a0033327a213656357
  Author: Jannik Silvanus <jannik.silvanus at amd.com>
  Date:   2023-01-23 (Mon, 23 Jan 2023)

  Changed paths:
    A llvm/test/Transforms/InstCombine/load-gep-overalign.ll

  Log Message:
  -----------
  [Transforms] Add lit test for instcombine on load into vector of overaligned elements.

The result is currently broken in two ways:

 - Valid loads are replaced by poison
 - An array-like layout with padding bytes is assumed

This commit serves as precommit for a patch that addresses the first issue.
The second issue will remain a TODO.

Contributors:
    Sebastian Neubauer <sebastian.neubauer at amd.com>


  Commit: a4753f5dc0a9bccf3706a82cacbd046c272eb814
      https://github.com/llvm/llvm-project/commit/a4753f5dc0a9bccf3706a82cacbd046c272eb814
  Author: Jannik Silvanus <jannik.silvanus at amd.com>
  Date:   2023-01-23 (Mon, 23 Jan 2023)

  Changed paths:
    M llvm/lib/IR/DataLayout.cpp
    M llvm/test/Transforms/InstCombine/load-gep-overalign.ll
    M llvm/test/Transforms/LowerMatrixIntrinsics/multiply-fused-dominance.ll

  Log Message:
  -----------
  [IR] Avoid creation of GEPs into vectors (in one place)

The method DataLayout::getGEPIndexForOffset(Type *&ElemTy, APInt &Offset)
allows to generate GEP indices for a given byte-based offset.
This allows to generate "natural" GEPs using the given type structure
if the byte offset happens to match a nested element object.

With opaque pointers and a general move towards byte-based GEPs [1],
this function may be questionable in the future.

This patch avoids creation of GEPs into vectors in routines that use
DataLayout::getGEPIndexForOffset by not returning indices in that case.

The reason is that A) GEPs into vectors have been discouraged for a long
time [2], and B) that GEPs into vectors are currently broken if the element
type is overaligned [1]. This is also demonstrated by a lit test where
previously InstCombine replaced valid loads by poison. Note that
the result of InstCombine on that test is *still* invalid, because
padding bytes are assumed.
Moreover, GEPs into vectors may be outright forbidden in the future [1].

[1]: https://discourse.llvm.org/t/67497
[2]: https://llvm.org/docs/GetElementPtr.html

The test case is new. It will be precommitted if this patch is accepted.

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


Compare: https://github.com/llvm/llvm-project/compare/b2cf024280b3...a4753f5dc0a9


More information about the All-commits mailing list